Middleware
Middlewares are functions that allow them to be executed before any route.
Example:
router.use((req, res) => {
req.executionStart = performance.now();
});
Multiple middlewares can be nested
router
.use((req, res) => {
// Middleware 1
})
.use((req, res) => {
// Middleware 2
})
.use((req, res) => {
// Middleware 3
});
NOTE: Remember that middlewares run according to the order that were created.
Last updated
Was this helpful?