cruky 0.5.0 copy "cruky: ^0.5.0" to clipboard
cruky: ^0.5.0 copied to clipboard

discontinuedreplaced by: croky
outdated

cruky is server-side library to create API with modern and fast performance.

cruky library logo

Info #

Cruky is a server-side library for the dart ecosystem to help you create your API as fast as possible. We want to make server-side apps with modern style and fast high performance

Inspired by FastApi

Get started #

You can see the todo example in the examples file it's very clear to understand.

  1. Install Dart from Dart.dev

  2. Install the Cruky package with dart pub global activate cruky

  3. Create dart project with dart create nameOfProject

  4. open the project with your favorite IDE like vscode

  5. And let's get started

First, we must add a library name for the file to import all routes in it and it must be unique to import the package in the file

library todos;
import 'package:cruky/cruky.dart';

/// data model
final List todos = [
  {"id": 1, "task": "task 1"},
  {"id": 2, "task": "task 2"},
];

Now let's add our first route method:

@Route.get('/todos/list/')
Future<List> listTodos() async => [];

Add the Route annotation to specify the route path, and add the method under it we can use the Future method or regular method (async or sync).

Return data from the method #

You can return a List or map for now and the response content type is just JSON for now.

Return specific status code #

you can return the specific status code with the map like that:

@Route.delete('/todos/:id(int)')
Map deleteTodo(int id) {
  todos.removeAt(request[id]);
  /// return custom status code
  return {
    #status: HttpStatus.ok,
    #body: {"msg": "the todo is deleted"}
  };
}

Now serve the app #

we can serve a simple app with this code

void main() => serve(host: '127.0.0.1', port: 5000);

and now run the dart file with cruky run filename.

This will run the file in ./bin/filename.dart with hot-reload.

You can run with another folder with cruky run filename -d example

This will run the file in ./example/filename.dart

Now Cruky will run the app with hot-reload if any thing changed in lib folder.

1
likes
0
pub points
0%
popularity

Publisher

unverified uploader

cruky is server-side library to create API with modern and fast performance.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

Dependencies

ansicolor, args, logging, mime, watcher

More

Packages that depend on cruky