This chapter deals with code organization. Abstraction usually means breaking monolithic logic into a few pieces. Most of the techniques presented in this chapter can be applied to any Node.js code, not just Express.js code.

An Express.js app usually has a main file (app.js or server.js). You should try to keep this file as small as possible, because as it grows larger, it becomes harder to maintain. The most suitable types of code to use instead of a large main file are middleware and routes. Configuration statements can also be abstracted, but they are typically less numerous than routes, which might exceed 200 to 300. ...

Get Pro Express.js now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.