# Middleware and Routers

Middleware and Routers: Middleware: Code That Runs on Every Request, Organizing Routes with express.Router.

Updated: November 19, 2026

1. [Middleware: Code That Runs on Every Request](https://www.ask-codey.com/lessons/node-express-middleware) (Journeyman): 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.
2. [Organizing Routes with express.Router](https://www.ask-codey.com/lessons/node-express-routers) (Journeyman): An express.Router holds one resource's routes in a file of its own, app.use("/games", gamesRouter) puts them under their path, and app.js exports the app while server.js starts it, so tests can use the app without a port.

Source: https://www.ask-codey.com/courses/nodejs-in-depth/topics/node-express-middleware-and-routers
