Lesson 28 / 34

Best Practices

Follow NestJS conventions: feature-based folders, DTO validation at the boundary and consistent error handling.

Folder structure & naming

One feature per folder; consistent naming (*.controller.ts, *.service.ts, *.module.ts); group by domain, not by type.

DTOs & validation

Always use DTOs for input validation; separate create/update DTOs; validate at the boundary (controller).

Error handling uniformity

Throw HTTP exceptions with clear messages; use a global filter to format responses consistently.