-
Book Overview & Buying
-
Table Of Contents
Node.js Design Patterns - Fourth Edition
By :
Every application is the result of the aggregation of several components, and as the application grows, the way we connect these components becomes a win-or-lose factor for the maintainability and success of the project.
When component A needs component B to fulfill a given functionality, we say that “A is dependent on B” or, conversely, that “B is a dependency of A.” To appreciate this concept, let’s present an example.
Let’s say we want to write an API for a blogging system that uses a database to store its data. We can have a generic module implementing a database connection (db.js) and a blog module that exposes the main functionality to create and retrieve blog posts from the database (blog.js).
The following figure illustrates the relationship between the database module and the blog module:

Figure 7.1: Dependency graph between the blog module and the database module
In this section, we are going...