Releases: YahooArchive/mojito
version 0.8.4
version 0.9.8
version 0.9.8
Features
- Updated to the latest version of YUI (3.18.x).
Bug Fixes
- Action context now inherits the addons required by any yui module required by a controller.
0.9.7
version 0.9.7
Features
- Controllers, models, and binders can be defined as a function with a prototype.
- Support for easily extending YUI modules in a different mojit, by using
Y.mojito.Util.extend
.
Y.mojito.Util.extend
, defined in 'mojito-util', is the equivalent of Y.extend, and can accept
object literals in addition to functions. - Controllers inherit the addons of any controller that is listed in its requires array.
- Mojit dependencies can be specified in defaults.json, which ensures that required dependencies are loaded when
resourceStore.lazyMojits
is set to true.
Below is an example where the ImageResult
controller extends the Result
controller:
mojits/Result/controller.server.js
YUI.add('ResultController', function (Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
index: function (ac) {
var result = this.createResultObject(ac);
ac.done({
result: result
});
},
createResultObject: function (ac) {
return {
title: ac.config.get('title'),
text: ac.config.get('text')
};
}
};
}, '0.0.1', {
requires: [
'mojito-config-addon'
]
});
mojits/ImageResult/controller.server.js
YUI.add('ImageResultController', function (Y, NAME) {
var ResultController = Y.mojito.controllers.ResultController,
// Constructor for this controller.
ImageResultController = function () {
// Hook into the original createResultObject method, in order
// to call this controller's augmentResult method.
Y.Do.after(this.augmentResult, this, 'createResultObject')
};
Y.namespace('mojito.controllers')[NAME] = ImageResultController;
// Extend the ResultController, adding the augmentResult custom method.
Y.mojito.Util.extend(ImageResultController, ResultController, {
augmentResult: function () {
Y.Do.currentRetVal.image = {
src: 'myImage'
};
}
});
}, '0.0.1', {
requires: [
'ResultController',
'mojito-util'
]
});
The ImageResult
controller uses Y.mojito.Util.extend
in order to extend the Result
controller and add custom methods. The controller is defined as a function that serves as a constructor. In this function, the controller hooks into createResultObject
in order to call augmentResult
after. Notice that the ImageResult
controller does not have to re-specify the config addon in its requires array since this addon is inferred from the required ResultController
.
Note:
If resourceStore.lazyMojits
is set to true, then mojits that depend on the resources of other mojits must let Mojito know of the dependencies. This ensures that once a mojit is lazy loaded, its dependency mojits are also loaded. Dependencies can be specified in the mojit's defaults.json. Below is how ImageResult's defaults.json would specify that it depends on resources in the Result mojit:
ImageResult/defaults.json
[{
"settings": ["master"],
"dependencies": ["Result"]
}]
0.9.6
version 0.9.6
Features
- Clearer and more specific error messages regarding invalid mojits and exceptions.
- Routes.json now accepts an annotations object (see express annotations). Also the "client" annotation can be used to specify whether to expose the route to the client; by default, routes are exposed to the client.
Ex. routes.json:
...
"route": {
"verbs": ["get"],
"path": "/path",
"call": "spec.action",
"annotations": {
"client": false
}
}
...
Bug Fixes
- Catching any uncaught exception during binder execution. This prevents binder errors from interfering with other binders and the mojito client.
0.9.5
version 0.9.5
Notes
- Reduced start up time by up to 25% by capturing YUI module details and executing them in one step instead of two.
- Now YUI modules are only executed once, with the real runtime YUI object scoped.
- Syntax errors are now reported with line numbers after failing to compile YUI modules.
- Better handling of translations in the Intl addon, which finds the best available lang while avoiding potential interference from a previously set language.
Bug Fixes
- Fixed issue where application start up would crash due to syntax errors in a YUI module.
0.9.4
Features
-
Added the
lazyLangs
andlazyMojits
options, which significantly reduce start up time. By default these options are set to false, and can be set to true under theresourceStore
option in application.json. After a resource is lazy loaded, it does not need to be loaded again in subsequent requests.lazyLangs
andlazyMojits
are ideal options for large applications during development when developers often have to restart an application and don't necessarily use all mojits or languages.-
lazyLangs
only loads the lang files necessary for a given request's lang context; this substantially reduces start up time for applications that have many lang files.Note that
lazyLangs
requires lang files to follow proper naming conventions ({mojitName}_{locale}.js or {mojitName}.js for default lang, e.g. Main_es-ES.js or Main.js); default langs are specified with the empty string within the lang file. -
lazyMojits
only loads mojits as they appear during a request; this option is especially useful for applications with many mojits that don't appear often.Note that if
lazyMojits
is on then YUI modules within mojits must let YUI know of any YUI modules it requires that are outside of the mojit. Usually this is not necessary since mojits are meant to be self contained, but if it is not, then let YUI know of the external YUI module with this code on top of the requiring YUI module:if (typeof YUI === 'function') { // Making sure the PipelineFrame controller is available to this module if lazyMojits is on. YUI().applyConfig({ modules: { PipelineFrameMojit: { fullpath: require('path').join(__dirname, '../PipelineFrame/controller.server.js') } } }); }
-
Bug Fixes
- Fixed issue where the mojito-handler-static middleware was sometimes setting the header max-age value to NaN.
0.9.3
Notes
- Various improvements to the Resource Store, which reduce start up time by 30% to 50%.
- YUI dependency was upgraded to [email protected]
- Request dependency was upgraded to [email protected]
- Yahoo Arrow devDependency was upgraded to [email protected]
0.9.2
Notes
- YUI dependency was upgraded to [email protected]
- Express State dependency was upgraded to [email protected]
- Express Map dependency was upgraded to [email protected]
- Glob dependency was upgraded to [email protected]
- JS-YAML dependency was upgraded to [email protected]
- Mime dependency was upgraded to [email protected]
- Semver dependency was upgraded to [email protected]
- Express devDependency was upgraded to [email protected]
0.9.1
Notes
- YUI dependency was upgraded to [email protected]
- Express State dependency was upgraded to [email protected]
- Express Map dependency was upgraded to [email protected]
- Glob dependency was upgraded to [email protected]
- JS-YAML dependency was upgraded to [email protected]
- Mime dependency was upgraded to [email protected]
- Semver dependency was upgraded to [email protected]
- Express devDependency was upgraded to [email protected]
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