Search⌘ K
AI Features

Implement Middleware

Explore how middleware functions in Express modify HTTP requests and responses, manage application flow by using next(), and handle tasks like logging and serving static files. This lesson helps you implement and understand application-level middleware in a Node.js RESTful API server.

In the previous lesson, we used a middleware function, express.static(), to serve static files to the client. We can use middleware functions for various tasks, such as logging, authentication, parsing data, and so on.

Middleware

Middleware functions are those that alter the request (req) and response (res) objects in the request-response cycle of an application.

New HTTP Request \large\Rightarrow ...