jaguar_auth_mongo 0.1.0

  • Readme
  • Changelog
  • Installing
  • --

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));

Changelog #

0.0.1 #

  • Initial version, created by Stagehand

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  jaguar_auth_mongo: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:jaguar_auth_mongo/jaguar_auth_mongo.dart';
Awaiting analysis to complete.