NestJS + MongoDB API Skill
This skill provides scaffolding templates, architectural patterns, and best practices for building production-grade NestJS REST APIs with MongoDB and Mongoose.
Quick Scaffolding Commands
When asked to generate a new module or feature, follow these steps:
- •Read
references/architecture.mdfor the clean architecture layer structure - •Read
references/naming-conventions.mdfor file and class naming rules - •Use
scripts/scaffold-module.shto generate the folder skeleton - •Fill in each file using the templates in
references/templates.md
Tech Stack
- •Framework: NestJS 10+
- •Database: MongoDB 7+
- •ODM: Mongoose 8+ via
@nestjs/mongoose - •Validation:
class-validator+class-transformer - •API Docs: Swagger via
@nestjs/swagger - •Config:
@nestjs/configwith Joi validation
Key References
- •
references/architecture.md— Clean architecture layer breakdown - •
references/naming-conventions.md— File, class, and variable naming rules - •
references/templates.md— Code templates for all layer files
Standard File Creation Checklist
For every new feature <Feature>, create:
code
src/ ├── domain/ │ ├── entities/<feature>.entity.ts │ ├── repositories/i-<feature>.repository.ts │ └── exceptions/<feature>.exceptions.ts ├── application/ │ ├── use-cases/create-<feature>.use-case.ts │ ├── use-cases/find-<feature>.use-case.ts │ ├── use-cases/update-<feature>.use-case.ts │ ├── use-cases/delete-<feature>.use-case.ts │ └── dtos/<feature>.dto.ts ├── infrastructure/ │ └── database/ │ ├── schemas/<feature>.schema.ts │ ├── repositories/mongoose-<feature>.repository.ts │ └── mappers/<feature>.mapper.ts ├── presentation/ │ └── controllers/<feature>.controller.ts └── <feature>.module.ts