Comparing version 1.0.2 to 1.0.3
38
index.js
@@ -9,6 +9,6 @@ glob = require('glob'); | ||
var seedModules = [], routes = {}; | ||
var seedNodules = [], routes = {}; | ||
var config = { | ||
// NOTE: the three route config params below must be specified in the module init method, they cannot be mutated at request-time | ||
// NOTE: the three route config params below must be specified in the nodule init method, they cannot be mutated at request-time | ||
// REQUIRED, must be unique within express app, can be an array of multiple routes | ||
@@ -28,35 +28,35 @@ route: null, | ||
// TODO - look for a cleaner way to do this inside the modules | ||
app.initModule = initModule; | ||
// TODO - look for a cleaner way to do this inside the nodules | ||
app.initNodule = initNodule; | ||
return { | ||
seedModules: seedModules, | ||
loadModules: loadModules, | ||
seedNodules: seedNodules, | ||
loadNodules: loadNodules, | ||
registerRoutes: registerRoutes | ||
}; | ||
function loadModules(dir, exclude) { | ||
function loadNodules(dir, exclude) { | ||
var root = dir || process.cwd(); // TOOD - should this be process.cwd() + '/app' ? | ||
glob.sync('./**/*.js', { cwd: root }) | ||
.filter(doesntMatch.apply(this, exclude)) | ||
.forEach(function(module) { require(path.join(root, module))(app); }); | ||
.forEach(function(nodule) { require(path.join(root, nodule))(app); }); | ||
} | ||
function initModule(file, config) { | ||
var seedModule = _.extend(_.cloneDeep(defaultConfig), config); // merge config properties onto default config | ||
seedModule.path = path.dirname(file); | ||
seedModule.name = path.basename(file, '.js'); | ||
function initNodule(file, config) { | ||
var seedNodule = _.extend(_.cloneDeep(defaultConfig), config); // merge config properties onto default config | ||
seedNodule.path = path.dirname(file); | ||
seedNodule.name = path.basename(file, '.js'); | ||
// modules can have multiple routes | ||
var routeArray = (typeof seedModule.route === 'string') || (seedModule.route instanceof RegExp) ? [seedModule.route] : seedModule.route; | ||
// nodules can have multiple routes | ||
var routeArray = (typeof seedNodule.route === 'string') || (seedNodule.route instanceof RegExp) ? [seedNodule.route] : seedNodule.route; | ||
_.each(routeArray, function(routePath) { | ||
seedModules[routePath] = seedModule; // routes must me unique | ||
seedNodules[routePath] = seedNodule; // routes must me unique | ||
if (!routes[seedModule.routeIndex]) | ||
routes[seedModule.routeIndex] = []; | ||
routes[seedModule.routeIndex].push({path:routePath, verb:seedModule.routeVerb}); | ||
if (!routes[seedNodule.routeIndex]) | ||
routes[seedNodule.routeIndex] = []; | ||
routes[seedNodule.routeIndex].push({path:routePath, verb:seedNodule.routeVerb}); | ||
}); | ||
} | ||
// register routes in order based on module.routeIndex (default 0, can be negative) | ||
// register routes in order based on nodule.routeIndex (default 0, can be negative) | ||
function registerRoutes(middlewares) { | ||
@@ -63,0 +63,0 @@ var middlewareString = middlewares.reduce(function(prev, curr, index, array) { |
{ | ||
"name": "nodulejs", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Utility for discovering and initializing node/express modules", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,1 +5,3 @@ nodulejs | ||
Lightweight framework for discovering and initializing node/express modules | ||
This will make more sense once I write some tests and upload the API frameowrk that uses it. I am separating it out so that frameworks based on other forms of back-end data-gathering can use it as well. |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
15367
7