Commit 6a949dc4 authored by Daffa 's avatar Daffa

add documentation for creating new modules and CRUD resources in README

parent 5152dcd0
Pipeline #2159 failed
...@@ -226,6 +226,71 @@ module.exports = { ...@@ -226,6 +226,71 @@ module.exports = {
npm run db:migrate npm run db:migrate
``` ```
## Creating New Modules
NestJS CLI provides a powerful generator to create new modules with all necessary files.
### Generate a complete CRUD resource:
```bash
nest g resource products
```
This will prompt you to:
- Choose transport layer (REST API, GraphQL, Microservice, WebSockets) - Select **REST API**
- Generate CRUD entry points? - Select **Yes**
This command creates:
```
src/modules/products/
├── dto/
│ ├── create-product.dto.ts
│ └── update-product.dto.ts
├── entities/
│ └── product.entity.ts
├── products.controller.ts
├── products.module.ts
├── products.service.ts
└── products.controller.spec.ts
```
### Other useful generators:
Generate a module only:
```bash
nest g module products
```
Generate a controller:
```bash
nest g controller products
```
Generate a service:
```bash
nest g service products
```
Generate a guard:
```bash
nest g guard auth/guards/custom
```
Generate a decorator:
```bash
nest g decorator common/decorators/custom
```
Generate a middleware:
```bash
nest g middleware common/middleware/custom
```
After generating a new module, remember to:
1. Create the corresponding Sequelize model in `src/database/models/`
2. Create a migration for the database table
3. Add the model to `SequelizeModule.forFeature([])` in your module
4. Update DTOs with proper validation decorators
## Contributors ## Contributors
- Daffa Praramadhana - [daffa.praramadhana@mdd.co.id](mailto:daffa.praramadhana@mdd.co.id) - Daffa Praramadhana - [daffa.praramadhana@mdd.co.id](mailto:daffa.praramadhana@mdd.co.id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment