0.9.0
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
andserver.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 viaapplication.json
.
Instead, the Expressapp
instance should calllisten()
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()
andY.mojito.RouteMaker.make()
no longer throws exception.
Instead, the api returnsnull
in order to provide the application more
control on how best to handle this error. -
The
ac.url.find()
andY.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 byname
orpath
. -
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
andloader-app-resolved
.
If you are using any of those 3 entries in the YUI configuration,
you should useloader-app
andloader-app-base
as your seed modules.
In fact we recommend to not customizeyui.config.seed
in yourapplication.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.
ac.config.getRoutes()
now returns the route configuration object using the
format fromexpress-map#getRouteMap()
.
New Dependencies
- Mojito now leverages the following packages for its routing implementation:
express-map
and
express-annotations