nestjs-mongoose-schematics
v0.1.7
Published
An opionionated schematics for generating mongoose schemas, with their controllers and DTOs for NestJS.
Downloads
12
Readme
nestjs-mongoose-schematics
🚧 Work in progress 🦺
This is an opinionated NestJS schematics for generating Mongoose models, DTOs, controllers, services, and repositories.
Usage
# Install the schematics
npm i --save-dev nestjs-mongoose-schematics
# Generate a new resource (controller + service + repository)
nest g -c nestjs-mongoose-schematics resource
Todo list for the alpha release
- [x] Basic entity with Mongoose Schema
- [x] Basic DTO with class validators annotations
- [x] Better controllers and services
- [x] Install NPM dependencies
- [x] Configure Mongoose module
- [x] Configure Mongoose feature
- [x] Use id instead of _id in responses
- [x] Create repository class
- [x] Swagger annotations
- [x] Install global pipe ValidationPipe in
main.ts
- [x] Install Swagger UI in
main.ts
- [ ] Unit tests with automock
- [ ] Unit test factories with Fishery
Todo list for the beta release
- [ ] Support nested objects
- [ ] Support references (relations)
- [ ] Support soft deletes
Development
Create a new NestJS project, which will be ignored by the .gitignore
file.
# Link the local development build of the schematics
cd nestjs-mongoose-schematics
npm install
npm build
npm link
# Create new example application inside the current directory
nest new example -p npm
cd example
npm i @nestjs/mongoose mongoose
npm link nestjs-mongoose-schematics
Run the schematics:
nest g -c nestjs-mongoose-schematics resource --debug