How to organize routes
So far, our routes and their handlers have been written right in the app file. It might work for small apps, but is not practical for bigger projects. After a certain level of complexity in our app, we will need to organize your routes.
So what is the Express way of organizing routes?
The Express way of organizing routes is—chose what works best for you. Express does not force, recommend, or suggest any form of routing pattern on its developers. However, it provides the capability to implement any sort of routing pattern you may want to implement for your app.
There are three popular ways of organizing routes in an Express app; let's explore them.
Using Node modules
In Chapter 1, What is Express?, we learned that Node modules can be of any JavaScript object type, including functions. Since route handlers are function, we can modularize our app by using Node nodules to define our route handlers.
Create a directory named routes
to keep our route handlers. In the directory...