Done same thing on the server so that when next() is called from the last middleware in the stack it will not throw. If no res.end() was specified in the last middleware it will be up to Express to finish the response.
The reason why I needed this feature is because I have many middlewares that are triggering next(), but they can be attached to the stack in a messy order (hooked up from different files). Even my very last middleware which prints the HTML to the browser contains next(). Which looks like so:
function(req, res, next) {
// run all other middlewares (if any) before continuing the current one
next()
...
res.end('html')
}
Done same thing on the server so that when
next()
is called from the last middleware in the stack it will not throw. If nores.end()
was specified in the last middleware it will be up to Express to finish the response.The reason why I needed this feature is because I have many middlewares that are triggering
next()
, but they can be attached to the stack in a messy order (hooked up from different files). Even my very last middleware which prints the HTML to the browser containsnext()
. Which looks like so: