nestjs-patterns

Implements NestJS architecture patterns for modular TypeScript backend APIs.

Updated Mar 18, 2026
One-click install
npx skills add https://github.com/freedom909/real-estate-saas --skill nestjs-patterns-freedom909
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nestjs-patterns
Source: https://github.com/freedom909/real-estate-saas/tree/main/.trae/skills/nestjs-patterns
Command: npx skills add https://github.com/freedom909/real-estate-saas --skill nestjs-patterns-freedom909

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building maintainable NestJS backends requires consistent decisions about module structure, validation, guards, error handling, and configuration. This Skill provides production-grade patterns so you avoid ad-hoc architectures, leaky DTOs, and inconsistent error responses. ## Core Features & Use Cases - Modular Project Structure: Organize feature modules, common filters, guards, interceptors, and config in a standard layout. - Validation and Error Handling: Apply global ValidationPipe settings, class-validator DTOs, and a unified exception filter envelope. - Auth and Config Patterns: Implement JWT guards, role-based access, and boot-time environment validation. - Use Case: When scaffolding a new NestJS microservice for a SaaS platform, use this Skill to generate the module layout, bootstrap with global pipes and filters, and add validated DTOs for each endpoint. ## Quick Start Ask the AI to scaffold a NestJS users module with a controller, service, validated create-user DTO, and JWT guard following these patterns.

Frequently Asked Questions about nestjs-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a NestJS project with modules and controllers?▼

Keep domain code inside feature modules under src/modules, with each module owning its controller, service, DTOs, and guards. Place cross-cutting filters, interceptors, and pipes in a common directory, and keep controllers thin by delegating business logic to injectable services.

How to add global DTO validation in NestJS?▼

Register a global ValidationPipe in the bootstrap function with whitelist, forbidNonWhitelisted, and transform enabled. Then annotate request DTOs with class-validator decorators like IsEmail, IsString, and Length so every endpoint validates input automatically.

Does NestJS support role-based authorization with guards?▼

Yes, combine a JwtAuthGuard with a RolesGuard using UseGuards and a Roles decorator to encode coarse access rules. Perform resource-specific authorization inside services rather than in guards for finer control.

Why should environment variables be validated at NestJS startup?▼

Validating env at boot with ConfigModule's validate option prevents the app from starting with invalid or missing configuration. This avoids lazy failures at first request and keeps config access behind typed helpers.

When should I not put logic in NestJS controllers?▼

Controllers should only parse HTTP input, call a provider, and return response DTOs. Business logic, multi-step writes, and transaction coordination belong in injectable services that own the unit of work.