mojito 0.2.0 copy "mojito: ^0.2.0" to clipboard
mojito: ^0.2.0 copied to clipboard

outdatedDart 1 only

A micro framework for modern web apps built from the ground up on the shelf framework

A micro framework for modern web apps built from the ground up on the shelf framework #

Build Status Pub Version

Introduction #

A micro framework for modern web apps built from the ground up on the Shelf Framework.

Like its namesake, Mojito is mostly sugar and a blend of other ingredients. Mojito is deliberately a very thin layer over several shelf packages and focuses on the overall experience of building an application.

The focus of Mojito is on modern rich web apps that have a clean separation of ui from services. As such it doesn't bundle any server side templating packages although these can be easily added.

The core architecture of Mojito is shelf itself. All components are existing pub packages that are built from the ground up as shelf components. This makes it super easy to take advantage of any new shelf based packages that come along in the future

Usage #

Import and initialise

 import 'package:mojito/mojito.dart';
 
 final app = mojito.init();

Set up some global authentication. These will be applied to all routes.

  app.auth.global
    .basic(_lookup)
    ..allowHttp=true
    ..allowAnonymousAccess=true;

Set up a route for the ui that will proxy to pub serve in dev and serve from the filesystem in prod.

app.router..addStaticAssetHandler('/ui');

Set up a route and get the authenticated users name from the context. Note: Mojito makes the logged in user available in the current zone.

app.router..get('/hi', () {
  var auth = app.context.auth;
  var username = auth.map((authContext) =>
      authContext.principal.name)
      .getOrElse(() => 'guest');

  return 'hello $username';
});

Start serving the app

app.start();

Under the hood #

Mojito bundles lots of existing shelf libraries and integrates them for easier use. These include:

More doco to come...

0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A micro framework for modern web apps built from the ground up on the shelf framework

Homepage

License

unknown (LICENSE)

Dependencies

oauth, option, shelf, shelf_auth, shelf_auth_session, shelf_bind, shelf_exception_response, shelf_oauth, shelf_path, shelf_proxy, shelf_rest, shelf_route, shelf_static

More

Packages that depend on mojito