NestJS middleware is functionally equivalent to Express middleware — it has access to req, res, and next(). The key difference is that NestJS middleware can be a class implementing NestMiddleware decorated with @Injectable(), giving it full access to the DI container. Functional middleware is still supported for simple stateless cases.
Express middleware — plain functions, no DI, registered with app.use().
NestJS class middleware — @Injectable() class, full DI support, applied via configure().
NestJS functional middleware — plain function, no DI, lighter weight for simple cases.
Both must call next() to pass control to the next handler or the request will hang.
NestJS middleware runs before routing — it has no knowledge of which controller handles the request.