Comparing version 0.2.0 to 0.3.0
@@ -5,2 +5,3 @@ | ||
// Modules | ||
var async = require('async'); | ||
var express = require('express'); | ||
@@ -19,6 +20,4 @@ var socketio = require('socket.io'); | ||
// TODO: Add configuration options | ||
// Add WebSockets | ||
var io = socketio(); | ||
app.socketio = io; | ||
app.socketio = socketio(); | ||
@@ -28,3 +27,2 @@ // Global Settings | ||
// TODO: Add configuration option | ||
// Serve static files before the routes | ||
@@ -35,27 +33,20 @@ if (options.static) { | ||
// Remove Header X-Powered-By | ||
app.disable('x-powered-by'); | ||
// Ensure req.locals exists | ||
app.use(function (req, res, next) { | ||
if (!req.locals) { req.locals = {}; } | ||
next(); | ||
}); | ||
// Attach Routes | ||
// Attach Routes Asynchronously | ||
if (options.routes) { | ||
if (!Array.isArray(options.routes)) { return new Error('options.routes needs to be an Array'); } | ||
for (var i = 0; i < options.routes.length; i++) { | ||
options.routes[i] (app); | ||
} | ||
} | ||
async.mapSeries(options.routes, function (route, done) { | ||
route(app, done); | ||
}, function (error) { | ||
// Catch-All Route (Not Found) | ||
app.use(response.not_found); | ||
// Catch-All Route (Not Found) | ||
app.use(response.not_found); | ||
// Error Handler | ||
app.use(response.failure); | ||
// Error Handler | ||
app.use(response.failure); | ||
}); | ||
} | ||
return app; | ||
}; |
{ | ||
"name" : "otto-app", | ||
"version" : "0.2.0", | ||
"version" : "0.3.0", | ||
"repository" : "https://github.com/ottojs/otto-app.git", | ||
"main" : "./lib/index.js", | ||
"dependencies" : { | ||
"async" : "1.4.2", | ||
"express" : "4.13.3", | ||
"socket.io" : "1.3.6", | ||
"otto-errors" : "0.2.0", | ||
"otto-config" : "0.2.0", | ||
"otto-config" : "0.3.0", | ||
"otto-response" : "0.4.0" | ||
@@ -12,0 +13,0 @@ }, |
@@ -28,3 +28,6 @@ | ||
subject({ | ||
routes : [ function (app) {} ] | ||
routes : [ | ||
function (app, done) { done(); }, | ||
function (app, done) { done(); } | ||
] | ||
}).should.have.property('get').and.be.type('function'); | ||
@@ -31,0 +34,0 @@ }); |
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
4729
6
60
+ Addedasync@1.4.2
+ Addedasync@1.4.2(transitive)
+ Addedcookie-parser@1.3.5(transitive)
+ Addedejs@2.3.3(transitive)
+ Addedotto-config@0.3.0(transitive)
+ Addedresponse-time@2.3.1(transitive)
- Removedotto-config@0.2.0(transitive)
Updatedotto-config@0.3.0