What is Middleware in Express.js? What are the
different types of Middleware?

Photo by Joan Gamell on Unsplash

What is Middleware in Express.js? What are the different types of Middleware?

Express is a routing and middleware web framework that has minimal functionality of its own: An Express application is essentially a series of middleware function calls.

Middleware functions are functions that have access to the request object (req), the response object (res), and the next middleware function in the application’s request-response cycle. The next middleware function is commonly denoted by a variable named next.

An Express application can use the following types of middleware:

  • Application-level middleware
  • Router-level middleware
  • Error-handling middleware
  • Built-in middleware
  • Third-party middleware

Source:

Using Express Middleware. expressjs.com/en/guide/using-middleware.html.