nestjs-module
SKILL.md
NestJS Module Architecture
This skill defines the responsibilities of the core module files. A module consists of:
- Service (
.service.ts): Business logic, calculations, and DTO transformation. - Controller (
.controller.ts): HTTP routing, documentation (Swagger), and request delegation. - Module (
.module.ts): Dependency Injection wiring.
1. Service Pattern (.service.ts)
Responsibilities:
- Injects the Repository to access data.
- Implements business rules (e.g., hashing passwords, sanitizing inputs).
- Transforms raw database results into clean objects (e.g., removing sensitive fields).
- Throws HTTP exceptions (
NotFoundException,ConflictException). - NEVER accesses the database directly (always use the Repository).