nestjs-crud-schematics
v0.3.3
Published
An opionionated NestJS schematics for generating Mongoose and TypeORM entities, with their controllers and DTOs.
Downloads
391
Readme
nestjs-crud-schematics
This is an opinionated NestJS schematics for generating Mongoose and TypeORM entities, DTOs, controllers, services, and repositories.
👾 These are the main differences between this generator and others:
- It only relies on offical and well-known packages
- It also generates the fields/properties for the entity
Usage
# Install the schematics
npm i --save-dev nestjs-crud-schematics
# Generate a new resource (controller + service + repository)
nest g -c nestjs-crud-schematics resource
Features
- Supports Mongoose or TypeORM (with Postgres)
- Installs all required NPM packages and NestJS modules
- Generates a controller, injecting a service
- Generates a service, injecting a repository
- Generates a custom repository serializing Mongoose documents into entities
- Generates the entity with either Mongoose or TypeORM decorators
- Generates DTOs with basic validators
- Generates Swagger documentation
- Generates unit tests with automock and full coverage
Development
Create a new NestJS project, which will be ignored by the .gitignore
file.
# Link the local development build of the schematics
cd nestjs-crud-schematics
npm install
npm build
npm link
# Create new example application inside the current directory
nest new example -p npm
cd example
npm link nestjs-crud-schematics
Run the schematics:
nest g -c nestjs-crud-schematics resource --debug