mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-26 20:36:17 +00:00
add not found route to the very end at development
This commit is contained in:
parent
0eee491edf
commit
b49593b13c
16
app.js
16
app.js
@ -239,6 +239,22 @@ Steppy(
|
|||||||
app.notifier.init(app.config.notify, this.slot());
|
app.notifier.init(app.config.notify, this.slot());
|
||||||
},
|
},
|
||||||
function() {
|
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
|
// load projects after all plugins to provide ability for plugins to
|
||||||
// handle `projectLoaded` event
|
// handle `projectLoaded` event
|
||||||
app.projects.loadAll(this.slot());
|
app.projects.loadAll(this.slot());
|
||||||
|
@ -35,6 +35,5 @@ Server.prototype._processRequestListeners = function(req, res, index) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.create = function() {
|
exports.create = function() {
|
||||||
return new Server;
|
return new Server();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user