In direct routes, you can pass a middleware to a route after the path, for example:
routes.get("/users", isAuthenticated, (req, res) => res.render("users"));
In resource routes, you can pass a middleware within an array after the Controller to execute for all resource methods, for example:
routes.resources("users", "UsersController", [isAuthenticated]);
But if you want to use a middleware in a specific resource method, you can pass an object with the method and middleware, for exemple:
routes.resources("users", "UsersController", [
isAuthenticated,
{ method: "store", middleware: upload().single("file") },
]);