A middleware is a (req, res, next) function that runs between receiving the request and sending the response. It can read or modify the request, respond itself, or pass control along. It holds cross-cutting tasks: logging, reading the JSON body (express.json()), authentication.
Example
app.use(express.json());
app.use((req, res, next) => { console.log(req.method, req.url); next(); });