Modules
A Nest.js application is organized into modules. If you’re familiar with modules in Angular, then the module syntax Nest uses will look very familiar.
Every Nest.js application will have a root module. In a small application, this may be the only module. In a larger application, it makes sense to organize your application into multiple modules that split up your code into features and related capabilities.
A module in Nest.js is a class with a @Module()
decorator. The @Module()
decorator takes a single object that describes module using the following properties.
Property | Description |
---|---|
components |
The components to be instantiated that may be shared across this module and exported to be available to other modules |
controllers |
The controllers that are created by this module |
imports |
The list of modules to import that export components that are requires in this module |
exports |
The list of components from this module to be made available to other modules |
In our example...