I am writing a web app in node.js using Express. I have defined a route as follows:
app.get(\"/firstService/:query\", function(req,res){ //trivial exampl
If you have a lot of middleware on your route, you can benefit from spreading:
const router = express.Router(); const myMiddleware = [ authenticationMiddleware(), validityCheckMiddleware(), myActualRequestHandler ]; router.get( "/foo", ...myMiddleware ); router.get( "/v1/foo", ...myMiddleware );