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

discontinuedreplaced by: croky
outdated

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

example/main.dart

import 'package:cruky/cruky.dart';
import 'package:cruky/handlers.dart';

void main() => runApp(MyApp(), debug: true);

class MyApp extends ServerApp {
  @override
  List get routes => [
        exampleWithGETRequest,
        getData,
        method,
        ExampleApp(),
      ];

  @override
  List get middlewares => [middlewareExample];

  @Route.get('/method')
  method(ReqCTX req) {
    return Redirect('/example/get');
  }
}

@Route.get('/')
exampleWithGETRequest(ReqCTX req) {
  return Json({'token': req.data['token']});
}

@Route.get('/:id(int)')
getData(ReqCTX req) {
  return Json({'id': req['id']});
}

@BeforeMW()
middlewareExample(ReqCTX req) {
  if (req.headerValue('Token') == null) {
    return Text('Not Auth', 401);
  } else {
    req.data['token'] = req.headerValue('Token')!;
  }
}

class ExampleApp extends AppMaterial {
  @override
  String get prefix => '/example';

  @override
  List get routes => [
        getExample,
      ];

  /// this is route method with path '/example/get/',
  ///
  /// And it will accept just json content-type request because of
  /// `JsonCTX` [req] type
  @Route.get('/get')
  getExample(JsonCTX req) {
    return Text('Nested apps');
  }
}
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, mime, mysql1, path, postgres, vm_service, watcher

More

Packages that depend on cruky