Chapter 4. Dependency Injection system of Nest.js
This chapter provides an overview of the Dependency Injection (DI) pattern, which is frequently used today by the biggest frameworks. It is a way to keep code clean and easier to use. By using this pattern you end up with fewer coupled components and more reusable ones, which helps accelerate the development process time.
Here we examine the method that used the injection before the pattern existed, and how the injection changed in time to use Nest.js injection with a modern approach using TypeScript and decorators. You will also see snippets that show the advantage of this type of pattern, and modules provided by the framework.
Nest.js is based on Angular in terms of architecture, and is used to create testable, scalable, loosely-coupled and easily maintainable applications. As is the case with Angular, Nest.js has its own dependency injection system, which is part of the core
of the framework, meaning that Nest.js is less dependent...