NestJS CLI Schematics for Dynamic Module Generation
Overview
This package contains a set of NestJS CLI schematics for generating modules that can be dynamically configured. The concepts behind the generated code is covered in detail in this article
Installation
Install the package globally as shown below. Due to the implementation of the NestJS CLI, the package must be global.
npm install -g @nestjsplus/dyn-schematics
Dynamic Package Generation
Currently, the primary use case supported is scaffolding a package containing a dynamic module. Such a package can easily be installed with npm, or packaged and distributed via the npm registry, or a private registry. In other words, a re-usable library. I'm also working on versions of the schematic to
- build a dynamic module within an existing NestJS application
- adding components to a dynamic module, such as additional options providers
Generate a new standalone dynamic package that will contain the customized skeleton of a dynamic module with:
nest g -c @nestjsplus/dyn-schematics dynpkg <pkg-name>
dynpkg is the name of the schematic to generate a standalone package containing a dynamic module.
<pkg-name> is the name of the new package you're building.
Move to the sub-folder just created:
cd <pkg-name> where pkg-name is the name you supplied in the original nest g command above.
Install the dependencies for the generated package:
npm install
Verify generated package
If you answered yes to the promptGenerate a testing client?, a small testing module was automatically generated called ClientModule. You can test that the template was properly generated by running
npm run start:dev
Then connect to http://localhost:3000. Your browser should display Hello from <pkg-name>Module!.
Customizing
The files in the project have comments that should help guide you.
You can also refer to this article for details on the concepts behind this module pattern.
Change Log
See Changelog for more information.
Contributing
Contributions welcome! See Contributing.
Author
John Biundo (Y Prospect on Discord)
License
Licensed under the MIT License - see the LICENSE file for details.