Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

0.9.0

Compare
Choose a tag to compare
@aljimenez aljimenez released this 24 Mar 22:14
· 156 commits to develop since this release

Notes

This release introduces a set of new APIs and concepts.

Please refer to some of the examples apps under the examples/ folder to get
an overview of what has changed.

Deprecations, Removals

  • Mojito no longer supports index.js and server.js to start up the server.
    Applications will instead instantiate Mojito as follows:

    var libmojito = require('mojito'),
        express = require('express'),
        app;
    
    app = express();
    libmojito.extend(app, { /* context */ });
    // at this point, access mojito instance via `app.mojito`
    
  • appPort configuration is no longer supported via application.json.
    Instead, the Express app instance should call listen() when ready.

  • Middleware configuration is no longer supported via application.json.
    Applications can register their middleware using the Express API. To enable
    Mojito default list of middleware, use the following:

    app.use(libmojito.middleware());
    

    If you want to have more granular control, use the following:

    app.use(libmojito.middleware['mojito-handler-static']());
    app.use(libmojito.middleware['mojito-parser-body']());
    app.use(libmojito.middleware['mojito-parser-cookies']());
    app.use(myCustomContextualizerMiddleware());
    app.use(libmojito.middleware['mojito-contextualizer']());
    app.use(libmojito.middleware['mojito-handler-tunnel']());
    app.use(anotherCustomMiddleware());
    
  • routes.json configuration is no longer loaded by default. To tell Mojito to
    do so, use the following:

    app.mojito.attachRoutes();
    

    Applications can also pass in an array of route configuration names if
    needed.

  • ac.url.make() and Y.mojito.RouteMaker.make() no longer throws exception.
    Instead, the api returns null in order to provide the application more
    control on how best to handle this error.

  • The ac.url.find() and Y.mojito.RouteMaker.find() methods are now
    deprecated and will be removed in a future version.

    Applications that rely on this API should familiarize with the express-map
    package by querying the route object by name or path.

  • Expanded metadata is now removed. This means we will not longer support
    synthetic modules that were expanded by default, e.g.:
    loader-yui3-base, loader-yui3-expanded and loader-app-resolved.
    If you are using any of those 3 entries in the YUI configuration,
    you should use loader-app and loader-app-base as your seed modules.
    In fact we recommend to not customize yui.config.seed in your application.json

Features

  • To register Mojito routes programmatically instead of using routes.json:
// app.js
app.get('/foo', mojito.dispatch('foo.index'));
app.map('/foo', 'foo');
app.map('/foo', 'get#foo.index');

In addition to setting up the path /foo to be routed to the Mojito
dispatcher, setup 2 additional "aliases". The second alias is the HTTP method
concatenated with the call value using the # delimiter.

This is equivalent to doing this in routes.json in previous releases.

[{
    "settings": [ "master" ],
    "foo": {
        verbs: [ "get" ],
        path: "/foo",
        call: "foo.index",
        params: { /* optional prams */ }
    }
}]

For more detail information, please check any of the applications under
examples/ folder.

New Dependencies