What problem does it solve?
Keep NestJS codebases maintainable by ensuring each module owns a coherent domain, controllers stay thin HTTP glue, services hold all business logic, and DTOs validate everything that crosses a boundary. Triggers on any change touching modules, controllers, services, providers, or DTOs.
Core Features & Use Cases
- Thin controllers: validate DTOs, authorize, delegate to services, and shape responses.
- Stateless services: avoid shared mutable state; use modules to define boundaries.
- Module export surface: publish a clear public API while hiding internals.
- Cross-module imports: route through a feature module's exported API to maintain encapsulation.
- Transaction placement: keep transactions in services or use-cases, not in controllers or repositories.
- DTO validation: use class-validator decorators and ValidationPipe with whitelist/forbidNonWhitelisted.
- Guard/interceptor/pipe scope: apply at the most specific level that achieves the goal.
Quick Start
Apply this guard to a NestJS module and refactor controllers to delegate to services while validating DTOs.