Generate NestJS Module
Generate a complete NestJS module following the DevPath project architecture.
Important: Follow the Learning Mode guidelines in
_templates/learning-mode.md
Arguments
$ARGUMENTS- Module name (e.g., "users", "lessons", "quizzes")
Instructions
When the user runs /nest-module <module-name>:
Step 1: Plan & Confirm
First, show the user what will be created:
backend/src/modules/<module-name>/
├── <module-name>.module.ts
├── <module-name>.controller.ts
├── <module-name>.service.ts
├── dto/
│ ├── create-<module-name>.dto.ts
│ └── update-<module-name>.dto.ts
Ask: "Bạn muốn bắt đầu từ file nào? Recommend: Service (chứa core logic)"
Step 2: Create files one by one
For EACH file:
- Write the code (max 50 lines)
- Explain what it does and WHY
- Ask: "Bạn hiểu phần này chưa? Có câu hỏi gì không?"
- Wait for confirmation before next file
Code Standards
Controller:
- Use
@Controller('api/v1/<module-name>')for versioned API - Include decorators:
@Get,@Post,@Patch,@Delete - Use
@ApiTagsfor Swagger documentation
- Use
Service:
- Inject
PrismaServicefor database operations - Use async/await pattern
- Throw proper NestJS exceptions
- Inject
DTOs:
- Use
class-validatordecorators - Use
class-transformerfor transformation
- Use
Module:
- Import required modules (PrismaModule, etc.)
- Export service if needed by other modules
After Completion
Remind user:
- "Nhớ update TRACKPAD.md với những gì đã học!"
- Suggest next steps (register in AppModule, create Prisma model, etc.)
- Link to NestJS docs if user needs more info
Converted and distributed by TomeVault — claim your Tome and manage your conversions.