Comparing version 1.1.0 to 1.1.1
@@ -13,10 +13,17 @@ var glob = require('glob'); | ||
// directories to look for nodules in, minus exclude pattern | ||
// directories to look for nodules in, minus exclude pattern - looks in nodules directory by default | ||
dirs: [ | ||
{ path: process.cwd(), exclude: null } | ||
{ path: path.join(process.cwd(), 'nodules'), exclude: null } | ||
], | ||
noduleDefaults: { | ||
// the array of middleware functions which will be called in order for each nodule | ||
// array of (or function which returns array of) middleware functions which will be called in order for each nodule on each express request | ||
middlewares: [], | ||
// - use a function if you want to specify different groups of middleware based on certain nodule properties when app inits | ||
// - but be careful because most nodule properties can be mutated at request time - whereas middleware chains are set up at app init time | ||
// function example (use 'this' to reference current nodule): | ||
// middlewares: function() { | ||
// if (this.routeVerb === 'post') return formMiddleWareArray; // predefined middleware array just for post requests | ||
// else return middleWareArray; // standard middleware array used for everything else | ||
// }, | ||
@@ -64,5 +71,5 @@ // NOTE: the three route config params below must be specified in the nodule init method, they cannot be mutated at request-time | ||
if (!routes[seedNodule.routeIndex]) | ||
routes[seedNodule.routeIndex] = []; | ||
routes[seedNodule.routeIndex].push({path:routePath, verb:seedNodule.routeVerb, middlewares:seedNodule.middlewares}); | ||
var middlewares = typeof seedNodule.middlewares === 'function' ? seedNodule.middlewares() : seedNodule.middlewares; | ||
if (!routes[seedNodule.routeIndex]) routes[seedNodule.routeIndex] = []; | ||
routes[seedNodule.routeIndex].push({path:routePath, verb:seedNodule.routeVerb, middlewares:middlewares}); | ||
}); | ||
@@ -87,3 +94,3 @@ } | ||
function initRequest(req, res, next) { | ||
req.module = _.cloneDeep(seedNodules[req.route.path]); | ||
req.nodule = _.cloneDeep(seedNodules[req.route.path]); | ||
next(); | ||
@@ -90,0 +97,0 @@ } |
{ | ||
"name": "nodulejs", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Utility for discovering and initializing node/express 'nodules'", | ||
@@ -5,0 +5,0 @@ "main": "nodule.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17885
100