Provides NestJS framework development standards and architectural patterns. Ensures domain-centric architecture, proper dependency injection, and decorator pattern utilization...
Organize modules by business domain, not by function.
controllers/, services/, repositories/users/, products/, orders/Each module is responsible for only one domain.
common/ or shared/ modulesProperty injection (@Inject) is forbidden.
// ✅ Good
constructor(private readonly userService: UserService) {}
// ❌ Bad
@Inject() userService: UserService;
Providers are registered only in the module where they are used.
Abstract repeated decorator combinations into custom decorators.
// Create custom decorator when combining 3+ decorators
@Auth() // Integrates @UseGuards + @ApiBearerAuth + @CurrentUser
Arrange in execution order from top to bottom.
Business logic is forbidden; only validation is allowed.
// ✅ Good: Validation only
class CreateUserDto {
@IsEmail()
email: string;
}
// ❌ Bad: Contains business logic
class CreateUserDto {
toEntity(): User {} // Forbidden
}
Never return Entity directly; always convert to DTO.
Each domain has its own Exception Filter.
@Module({
providers: [
{
provide: APP_FILTER,
useClass: UserExceptionFilter,
},
],
})
Always throw Exception explicitly in all error situations.