Modules
Organize your application into modules.
This guide is based of NestJS documentation.
After creating a new plugin, you can organize your work into modules. Modules are a way to group related components together. They can contain controllers, services, and other components.
Creating a module
To create a new module, create example.module.ts
in the apps/backend/src/plugins/{your_plugin_code}
directory. The module should be decorated with the @Module
decorator. Name of the module should be unique, best practice is to use {feature}{plugin_code}Module
as the name.
The @Module()
decorator takes an object with the following properties:
Property | Description |
---|---|
imports | Modules that are imported by this module. |
controllers | Controllers that are part of this module. |
providers | Services that are part of this module. |
exports | Providers that are exported by this module and can be used by other modules. |
Importing a module
Make this module available. Go to the module root
of your plugin. That's should be apps/backend/src/plugins/{your_plugin_code}/{your_plugin_code}.module.ts
. Import the module and add it to the imports
array.
Advanced usage
If you want to use global module, dynamic module please refer to the NestJS documentation.