From fa5176dcf97b8aa28885a3fb3599e3de6bfb3eb6 Mon Sep 17 00:00:00 2001 From: Manav Delvadiya Date: Wed, 11 Mar 2026 19:20:53 +0530 Subject: [PATCH 1/7] Improve controller example by adding DTO folder explanation --- content/controllers.md | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/content/controllers.md b/content/controllers.md index 0bc1cec08a..ae1ffddd92 100644 --- a/content/controllers.md +++ b/content/controllers.md @@ -533,6 +533,71 @@ export class CatsController { } ``` +#### DTO definitions used in the full example + +In the **Full resource sample** below, the controller imports several DTO classes: + +```typescript +import { CreateCatDto, UpdateCatDto, ListAllEntities } from './dto'; +``` + +Below is an example implementation of these DTO classes. + +##### create-cat.dto.ts + +```typescript +export class CreateCatDto { + name: string; + age: number; + breed: string; +} +``` + +##### update-cat.dto.ts + +```typescript +export class UpdateCatDto { + name?: string; + age?: number; + breed?: string; +} +``` + +##### list-all-entities.dto.ts + +```typescript +export class ListAllEntities { + limit?: number; + offset?: number; +} +``` + +Optionally, you can create an `index.ts` file inside the `dto` directory to simplify imports. + +```typescript +export * from './create-cat.dto'; +export * from './update-cat.dto'; +export * from './list-all-entities.dto'; +``` + +Example folder structure: + +``` +cats/ +├── cats.controller.ts +├── dto/ +│ ├── create-cat.dto.ts +│ ├── update-cat.dto.ts +│ ├── list-all-entities.dto.ts +│ └── index.ts +``` + +This structure allows importing all DTOs from a single location: + +```typescript +import { CreateCatDto, UpdateCatDto, ListAllEntities } from './dto'; +``` + > info **Hint** Nest CLI offers a generator (schematic) that automatically creates **all the boilerplate code**, saving you from doing this manually and improving the overall developer experience. Learn more about this feature [here](/recipes/crud-generator). #### Getting up and running From 326bc475114994535b3ab3fe235107d93f3d9b0c Mon Sep 17 00:00:00 2001 From: Manav Delvadiya Date: Sun, 15 Mar 2026 09:42:04 +0530 Subject: [PATCH 2/7] fix(docs): adjust DTO example formatting --- content/controllers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/controllers.md b/content/controllers.md index ae1ffddd92..085c9b9c53 100644 --- a/content/controllers.md +++ b/content/controllers.md @@ -598,7 +598,7 @@ This structure allows importing all DTOs from a single location: import { CreateCatDto, UpdateCatDto, ListAllEntities } from './dto'; ``` -> info **Hint** Nest CLI offers a generator (schematic) that automatically creates **all the boilerplate code**, saving you from doing this manually and improving the overall developer experience. Learn more about this feature [here](/recipes/crud-generator). +> **Hint** Nest CLI offers a generator (schematic) that automatically creates **all the boilerplate code**, saving you from doing this manually and improving the overall developer experience. Learn more about this feature [here](/recipes/crud). #### Getting up and running From 1f85bd5ffc76ea0da1dcf287bef01f77e9d7358d Mon Sep 17 00:00:00 2001 From: Manav Delvadiya Date: Sun, 15 Mar 2026 09:51:06 +0530 Subject: [PATCH 3/7] fix(docs): resolve markdown heading/code block issue --- content/controllers.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/controllers.md b/content/controllers.md index 085c9b9c53..b67c11baae 100644 --- a/content/controllers.md +++ b/content/controllers.md @@ -543,7 +543,7 @@ import { CreateCatDto, UpdateCatDto, ListAllEntities } from './dto'; Below is an example implementation of these DTO classes. -##### create-cat.dto.ts +**create-cat.dto.ts** ```typescript export class CreateCatDto { @@ -553,7 +553,7 @@ export class CreateCatDto { } ``` -##### update-cat.dto.ts +**update-cat.dto.ts** ```typescript export class UpdateCatDto { @@ -563,7 +563,7 @@ export class UpdateCatDto { } ``` -##### list-all-entities.dto.ts +**list-all-entities.dto.ts** ```typescript export class ListAllEntities { From 9066b2ae279674765413b08fed36f0f64eac6ea9 Mon Sep 17 00:00:00 2001 From: Manav Delvadiya Date: Sun, 15 Mar 2026 10:16:26 +0530 Subject: [PATCH 4/7] docs(controllers): simplify DTO examples to avoid markdown parsing issue --- content/controllers.md | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/content/controllers.md b/content/controllers.md index b67c11baae..24691f92bc 100644 --- a/content/controllers.md +++ b/content/controllers.md @@ -543,38 +543,28 @@ import { CreateCatDto, UpdateCatDto, ListAllEntities } from './dto'; Below is an example implementation of these DTO classes. -**create-cat.dto.ts** - ```typescript +// create-cat.dto.ts export class CreateCatDto { name: string; age: number; breed: string; } -``` - -**update-cat.dto.ts** -```typescript +// update-cat.dto.ts export class UpdateCatDto { name?: string; age?: number; breed?: string; } -``` -**list-all-entities.dto.ts** - -```typescript +// list-all-entities.dto.ts export class ListAllEntities { limit?: number; offset?: number; } -``` -Optionally, you can create an `index.ts` file inside the `dto` directory to simplify imports. - -```typescript +// dto/index.ts export * from './create-cat.dto'; export * from './update-cat.dto'; export * from './list-all-entities.dto'; From 20e8cf9d7c3a4b6b43b38d5566f116c69a6e5f7c Mon Sep 17 00:00:00 2001 From: Manav Delvadiya Date: Sun, 15 Mar 2026 10:27:25 +0530 Subject: [PATCH 5/7] docs(controllers): fix CRUD generator link and DTO example --- content/controllers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/controllers.md b/content/controllers.md index 24691f92bc..f45f07f787 100644 --- a/content/controllers.md +++ b/content/controllers.md @@ -588,7 +588,7 @@ This structure allows importing all DTOs from a single location: import { CreateCatDto, UpdateCatDto, ListAllEntities } from './dto'; ``` -> **Hint** Nest CLI offers a generator (schematic) that automatically creates **all the boilerplate code**, saving you from doing this manually and improving the overall developer experience. Learn more about this feature [here](/recipes/crud). +> **Hint** Nest CLI offers a generator (schematic) that automatically creates **all the boilerplate code**, saving you from doing this manually and improving the overall developer experience. Learn more about this feature [here](https://docs.nestjs.com/recipes/crud-generator#crud-generator). #### Getting up and running From 541f2efd1a6675fe73054c342f7f21e52c63dcc7 Mon Sep 17 00:00:00 2001 From: Manav Delvadiya Date: Sun, 15 Mar 2026 10:49:52 +0530 Subject: [PATCH 6/7] docs(controllers): add DTO file examples for full resource sample --- content/controllers.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/content/controllers.md b/content/controllers.md index f45f07f787..4a8389597e 100644 --- a/content/controllers.md +++ b/content/controllers.md @@ -544,27 +544,31 @@ import { CreateCatDto, UpdateCatDto, ListAllEntities } from './dto'; Below is an example implementation of these DTO classes. ```typescript -// create-cat.dto.ts +@@filename(create-cat.dto) export class CreateCatDto { name: string; age: number; breed: string; } -// update-cat.dto.ts +@@filename(update-cat.dto) export class UpdateCatDto { name?: string; age?: number; breed?: string; } -// list-all-entities.dto.ts +@@filename(list-all-entities.dto) export class ListAllEntities { limit?: number; offset?: number; } +``` + +To simplify imports, you can create an `index.ts` file within the `dto` folder to export all DTOs: -// dto/index.ts +```typescript +@@filename(index) export * from './create-cat.dto'; export * from './update-cat.dto'; export * from './list-all-entities.dto'; @@ -585,10 +589,11 @@ cats/ This structure allows importing all DTOs from a single location: ```typescript +@@filename(cats.controller) import { CreateCatDto, UpdateCatDto, ListAllEntities } from './dto'; ``` -> **Hint** Nest CLI offers a generator (schematic) that automatically creates **all the boilerplate code**, saving you from doing this manually and improving the overall developer experience. Learn more about this feature [here](https://docs.nestjs.com/recipes/crud-generator#crud-generator). +> **Hint** Nest CLI offers a generator (schematic) that automatically creates **all the boilerplate code**, saving you from doing this manually and improving the overall developer experience. Learn more about this feature [here](/recipes/crud). #### Getting up and running From b7d93c524537d4c1ea38ef2131dcb6a3d387b1f5 Mon Sep 17 00:00:00 2001 From: Manav Delvadiya Date: Sun, 15 Mar 2026 10:54:59 +0530 Subject: [PATCH 7/7] docs(controllers): fix indentation in example folder structure for DTOs --- content/controllers.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/controllers.md b/content/controllers.md index 4a8389597e..e07ebcbd20 100644 --- a/content/controllers.md +++ b/content/controllers.md @@ -579,11 +579,11 @@ Example folder structure: ``` cats/ ├── cats.controller.ts -├── dto/ -│ ├── create-cat.dto.ts -│ ├── update-cat.dto.ts -│ ├── list-all-entities.dto.ts -│ └── index.ts +└── dto/ + ├── create-cat.dto.ts + ├── update-cat.dto.ts + ├── list-all-entities.dto.ts + └── index.ts ``` This structure allows importing all DTOs from a single location: