jaguar_auth_mongo 0.2.0 icon indicating copy to clipboard operation
jaguar_auth_mongo: ^0.2.0 copied to clipboard

[pending analysis]

Jaguar AuthModelManager for MongoDb backend

jaguar_auth_mongo #

Jaguar AuthModelManager for MongoDb backend

Usage #

A simple usage example:

class BaseApi {
  BasicAuth basicAuth(Context ctx) =>
      new BasicAuth(modelManager(ctx.getInput(MongoDb)));

  Authorizer authorizer(Context ctx) =>
      new Authorizer(modelManager(ctx.getInput(MongoDb)));

  MongoDb mongoDb(Context ctx) => new MongoDb('mongodb://localhost:27018/test');

/// This route group contains login and logout routes
class AuthRoutes extends BaseApi {
  @Post(path: '/login')
  void login(Context ctx) {}

  @Post(path: '/logout')
  void logout(Context ctx) {
    //TODO logout

/// Collection of routes students can also access
@Api(path: '/book')
@Wrap(const [#mongoDb, #authorizer])
class StudentRoutes extends BaseApi {
  @Get(path: '/all')
  Response<String> getAllBooks(Context ctx) {
    List<Map> ret = book) => bookSerializer.toMap(book)).toList();
    return Response.json(ret);

  @Get(path: '/:id')
  Response<String> getBook(Context ctx) {
    final String id = ctx.pathParams.get('id');
    final Book book = _books[id];
    return Response.json(bookSerializer.toMap(book));