Organelle for glob
-ing a directory of actions modules and mounting them to expressjs app
{
"source": "node_modules/organic-express-routes",
"reactOn": "ExpressServer",
"pattern": "/**/*.js",
"path": "path/to/routes",
"helpers": "path/to/routes-helpers",
"mount": "/myroutes",
"log": false,
"emitReady": "ExpressRoutes"
}
Should be either ExpressServer
chemical with expected structure or array of chemicals where the first one is mapped as ExpressServer
chemical.
Optional, if provided with directory path will load all files matching given pattern
.
Optional, if provided all route handlers will be mounted to express app with given value as prefix.
Indicates the type of the chemical to be emitted once loading and mounting is complete
module.exports = function(plasma, dna, helpers) {
return {
"GET": expressHandler,
"POST": [expressHandler, ...],
"PUT /:id": expressHandler,
"DELETE /inner/url/:id": helpers["expressHandlerBuilder"](),
"OPTIONS": function(req, res, next) {
next()
}
}
}