Is there a way to make this on a single function call?
var todo = function (req, res){};
app.get(\"/\", todo);
app.get(\"/blabla\", todo);
app.get(\"/blabla
Just to elaborate on Kevin's answer, this is from the 4.x docs:
The path for which the middleware function is invoked; can be any of:
- A string representing a path.
- A path pattern.
- A regular expression pattern to match paths.
- An array of combinations of any of the above.
They have some examples, including:
This will match paths starting with
/abcd,/xyza,/lmn, and/pqr:app.use(['/abcd', '/xyza', /\/lmn|\/pqr/], function (req, res, next) { next(); });