diff --git a/app.js b/app.js index 78f6200..3ac9439 100644 --- a/app.js +++ b/app.js @@ -239,6 +239,22 @@ Steppy( app.notifier.init(app.config.notify, this.slot()); }, function() { + // only at development and only when there is no other request listeners + // (e.g. socketio) add not found route to the very end (after all + // plugins register) + if ( + env === 'development' && + app.httpServer._events && + _(app.httpServer._events.request).isFunction() + ) { + app.httpServer.addRequestListener(function(req, res, next) { + if (!res.headersSent) { + res.statusCode = 404; + res.end(req.method.toUpperCase() + ' ' + req.url + ' Not Found'); + } + }); + } + // load projects after all plugins to provide ability for plugins to // handle `projectLoaded` event app.projects.loadAll(this.slot()); diff --git a/lib/httpServer.js b/lib/httpServer.js index 8872c86..26991d5 100644 --- a/lib/httpServer.js +++ b/lib/httpServer.js @@ -35,6 +35,5 @@ Server.prototype._processRequestListeners = function(req, res, index) { }; exports.create = function() { - return new Server; + return new Server(); }; -