Comparing version 0.2.8 to 0.2.9
@@ -1,8 +0,7 @@ | ||
'use strict'; | ||
var express = require('express'); | ||
var logger = require('./logger'); | ||
var findFiles = require('./findFiles'); | ||
var express = require('express'), | ||
logger = require('./logger'), | ||
findFiles = require('./findFiles'); | ||
var async = require('async'); | ||
var _ = require('lodash'); | ||
@@ -21,2 +20,24 @@ function toRouter(r) { | ||
function toLogs(files) { | ||
var routes = _.chain(files) | ||
.map(function(r) { | ||
var routePaths = []; | ||
_.forIn(r, function(v, k) { | ||
routePaths.push(k); | ||
}); | ||
return routePaths; | ||
}) | ||
.reduce(function(a, b) { return a.concat(b); }) | ||
.sortBy() | ||
.value(); | ||
logger.debug('Added routes'); | ||
routes.forEach(function(r) { | ||
logger.debug(r); | ||
}); | ||
} | ||
module.exports = function(cb, app, path) { | ||
@@ -36,3 +57,4 @@ var _paths = path; | ||
files.map(function(f) { | ||
// Require route file and create express router | ||
var routeFiles = files.map(function(f) { | ||
var r = require(f); | ||
@@ -46,11 +68,11 @@ | ||
return {router: toRouter(r, prefix), path: '', name: prefix}; | ||
}) | ||
.forEach(function(r) { | ||
var route = '/' + r.path; | ||
app.use('/', toRouter(r, prefix)); | ||
app.use(route, r.router); | ||
logger.debug('Added routes for /' + r.name); | ||
// return {router: toRouter(r, prefix), path: '', name: prefix}; | ||
return r; | ||
}); | ||
// Log out all routes that were found and added | ||
toLogs(routeFiles); | ||
return done(); | ||
@@ -57,0 +79,0 @@ }); |
{ | ||
"name": "elephas", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"description": "Some added sugar on top of express to give our our some sensible defaults and a little structure.", | ||
@@ -5,0 +5,0 @@ "main": "elephas.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
33438
689