O'Reilly logo

Pro Express.js by Azat Mardan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 10

image

Abstraction

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required