In this section, you’ll learn how to create modular APIs using an Express Router. Organizing your APIs into Routers is a code-health technique that helps you reason about your code and facilitates refactoring and maintenance.
You can think of a Router like an Express subapplication. It has its own middleware stack and can contain routes.
With an Express Application, app, you can call app.use to delegate to a Router. Routers themselves can use other Routers in addition to having their own middleware and routes. This flexibility allows you to combine middleware and routes in a modular, maintainable way.
The APIs you’ll develop in this section will be similar to those you worked on in Chapter 7, Developing RESTful ...