Code Generation
Installation
Make sure you have the Awesome Nest Schematics installed in your project.
If you don't have it installed, you can install it by running the following command:
pnpm add -D awesome-nest-schematicsUsage
To generate code using the schematics, run the following command:
$ nest g -c awesome-nestjs-schematics <schematic>OR
$ pnpm generate<schematic> <name>For example, to generate a new controller:
$ pnpm generatecontrollerGenerators and Their Commands
Resource Generator
Generate a new Nest resource, including a controller, service, and module.
$ pnpm generateresourceDTO: Generate a new Data Transfer Object.
bash$ pnpm generatedtoController: Generate a new Nest controller.
bash$ pnpm generatecontrollerDecorator: Generate a new Nest decorator.
bash$ pnpm generatedecoratorFilter: Generate a new Nest filter.
bash$ pnpm generatefilterGuard: Generate a new Nest guard.
bash$ pnpm generateguardInterceptor: Generate a new Nest interceptor.
bash$ pnpm generateinterceptorInterface: Generate a new Nest interface.
bash$ pnpm generateinterfaceMiddleware: Generate a new Nest middleware.
bash$ pnpm generatemiddlewareModule: Generate a new Nest module.
bash$ pnpm generatemodulePipe: Generate a new Nest pipe.
bash$ pnpm generatepipeProvider: Generate a new Nest provider.
bash$ pnpm generateproviderService: Generate a new Nest service.
bash$ pnpm generateservice
Stay in touch
- Website - https://nestjs.com
- Twitter - @nestframework
License
Nest is MIT licensed.