# Middleware: Code That Runs on Every Request

Middleware is a function with (req, res, next) that Express runs on a request before the routes, in the order you add it, so a log line, a timer or a body reader is written once instead of in every route.

![Cheat sheet: Middleware: Code That Runs on Every Request](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/5112401a4eaa4075ac14a3fb90978ab7.webp)

- Category: Node.js
- Level: Journeyman
- Tags: &lt;header>, Middleware in Express, nodejs, req and res, rest-api, Static Files in Express
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/node-express-middleware-cheat-sheet
