Router-level middleware functions are only executed inside a router. They are usually used when applying a middleware to a mount point only or to a specific path.
Writing router-level middleware functions
Getting ready
In this recipe, you will create a small logger router-level middleware function that will only log requests to paths mounted or located in the router's mounted path. Before you start, create a new package.json file with the following content:
{ "dependencies": { "express": "4.16.3" } }
Then, install the dependencies by opening a Terminal and running:
npm install