In the mongoose
exercises, the last middleware is:
// Unmatched routes handler
app.use(function (req, res) {
if (req.method.toLowerCase() === "options") {
res.end();
} else {
res.status(404).type("txt").send("Not Found");
}
});
this will only be executed when a request does not match neither the previous routes+methods. Now, why not writing this:
// Unmatched routes handler
app.use(function (req, res) {
res.status(404).type("txt").send("Not Found");
});
Surely I’m missing something, so that’s why I’d like some ideas!!