@duyanhit/nestjs-schematics
v1.0.4
Published
Nest - modern, fast, powerful node.js web framework (@schematics)
Downloads
1
Readme
Description
This package extends all functions from @nestjs/schematics and has more customization ones. This package helps a lot in generating CRUD module. It is so useful when you work with ORM like Typeorm or Mongoose.
Installation
$ npm install -d @duyanhit/nestjs-schematics
Usage
After installing, make sure you have adjusted your configuration in nest-cli.json
{
...
"collection": "@duyanhit/nestjs-schematics",
...
}
Now, let's try yourself with a new feature.
CRUD
This function will generate a whole CRUD module base on your chosen ORM
$ nest g crud name
It will ask you about the transport layer. Currently, it just supports 2 layers Restful
and GraphQL (code first)
? What transport layer do you use? (Use arrow keys)
❯ Restful API
GraphQL (code first)
Next, you can choose which ORM you want to use
? What ORM do want to you use? (Use arrow keys)
❯ Typeorm
Mongoose
Prisma
Sequelize
Specifically, this function supports generating module with CQRS pattern.
? Would you want to use CQRS pattern? (Y/n)
After you have done, the tree can be like this:
src/apis/user
├── commands
│ ├── create-user.command.ts
│ ├── remove-user.command.ts
│ └── update-user.command.ts
├── dto
│ ├── create-user.dto.ts
│ ├── paginated-user.dto.ts
│ └── update-user.dto.ts
├── entities
│ └── user.entity.ts
├── handlers
│ ├── create-user.handler.ts
│ ├── find-one-user.handler.ts
│ ├── find-user.handler.ts
│ ├── remove-user.handler.ts
│ └── update-user.handler.ts
├── queries
│ ├── find-one-user.query.ts
│ └── find-user.query.ts
├── user.controller.ts
├── user.interface.ts
├── user.module.ts
├── user.service.ts
└── user.swagger.ts
Stay in touch
Thanks for considering this package. I hope you enjoy it. :) This package is still developed. I will make it better with more amazing features. If you have any ideas or questions, contact me through:
- Email - [email protected]
- Linkedin - Linkedin