NestJS tips
5 tips · newest first
Focused NestJS tips on pipes, dependency injection, validation, and clean production setups — small snippets that fix real backend pain points.
Throw IntrinsicException for expected errors to skip Nest's auto-logger
NESTJSNestJS 11 added IntrinsicException: throwing it bypasses the framework's automatic error logging while still propagatin…
Validate and convert date query params at the boundary with ParseDatePipe
NESTJSNestJS 11 ships ParseDatePipe, which validates an incoming date string and hands your handler a real Date. Parsing date…
Skip the HTTP layer for workers and CLI with createApplicationContext()
NESTJScreateApplicationContext() boots the DI container without starting an HTTP server. For cron jobs, queue consumers, and…
Keep the SWC builder (default in Nest 11) for ~20x faster builds
NESTJSNest 11 defaults to the Rust-based SWC compiler, which is dramatically faster than tsc for builds and dev restarts. SWC…
Configure a strict global ValidationPipe to strip unknown fields and coerce DTOs
NESTJSwhitelist: true removes any property not declared with a validation decorator — your defense against mass-assignment, s…