Nest.js Dependency Injection
From the @nestjs/common
you have access to the decorators provided by the framework and one of them is the @Module()
decorator. This decorator is the main decorator to build all of your modules and work with the Nest.js Dependency Injection system between them.
Your application will have at least one module, which is the main one. The application can use only one module (the main one) in the case of a small app. Nonetheless, as your app grows, you will have to create several modules to arrange your app for the main module.
From the main module, Nest will know all of the related modules that you have imported, and then create the application tree to manage all of the Dependency Injections and the scope of the modules.
To do this, the @Module()
decorator respects the ModuleMetadata
interface,
which defines the properties allowed to configure a module.
export
interface
ModuleMetadata
{
imports?
:any
[];
providers?
:any
[];
controllers?
:any
...