The checkpoint system between request and response — where logging, authentication, and validation live.
When I first saw this code in Express, I had no idea what it was doing:
app . use (( req , res , next ) => { console . log ( ` ${ req . method } ${ req . url } ` ); next (); });
Enter fullscreen mode
Exit fullscreen mode
It's not a route. It doesn't send a response. And what's next() ? Why do we need to call it? What happens if we don't?
This, I learned, is middleware — and it's the most powerful concept in Express. Every request that hits your server passes through middleware before it reaches your route handler. It's where you log requests, check authentication, validate data, parse bodies, and handle errors — all without cluttering your route logic.
Understanding middleware was the moment Express went from "a routing library" to "a complete application framework" in my mind.…