Skip to content

Instantly share code, notes, and snippets.

@saich
Last active December 11, 2015 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saich/4570725 to your computer and use it in GitHub Desktop.
Save saich/4570725 to your computer and use it in GitHub Desktop.
Useful links for Yahoo! Mojito
  • Controller YUI module name should be same as directory (i.e; same name as Mojit)
  • addon namespace should match the filename. E.g. ac.foo corresponds to addons/ac/foo.common.js.

Applicable atleast to Yahoo! Mojito v0.5.3-1.

  • Middlewares are declared in the application.json.
  • The way the middleware works depends on the file name of the middleware.
  • If file name starts with mojito- (e.g: mojito-logger.js):
    • The exported function should return a function, that can be called with express's app.use. For example, you can return express.logger() and the framework shall call app.use(express.logger()) using this return value.
    • This approach is suitable to use app.use, since the express's app is not exposed in the Mojito framework.
    • The configuration received by this function is of form: { Y: Y, store: store, logger: { log: Y.log }, context: options.context }
    • Tip: You can use require('mojito/node_modules/express') to use express from Mojito's dependencies, instead of adding a direct dependency on express in your package.json.
  • For all other files, it acts like a normal express middleware, which is called for every request with the express's request, response and next parameters, and should call next() to pass control to other middleware.

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment