NestJS From Zero
Learn the opinionated, TypeScript-first Node framework for structured backends: controllers and routing, providers and dependency injection, modules, DTOs and validation pipes, building a REST API with a service layer, guards and interceptors and middleware, and testing and production. Angular-style architecture over Express or Fastify.
- What NestJS Is & Your First App NestJS brings real architecture to Node — controllers, providers, dependency injection, and modules wired by decorators. Scaffold an app with the CLI, read main.ts, and serve your first JSON route.
- Controllers & Routing How controllers map HTTP requests to methods: @Controller base paths, route decorators, parameter decorators for params/query/body, and returning values that Nest auto-serializes to JSON.
- Providers & Dependency Injection How Nest's @Injectable services hold your logic and how the IoC container wires them into controllers via constructor injection — thin controllers, swappable deps, and the startup errors when wiring breaks.
- Modules Modules group a feature's controllers and providers; the app is a tree of modules rooted at AppModule. Learn @Module, imports/exports, and why providers are private by default.
- DTOs, Validation & Pipes Describe request bodies with DTO classes, annotate them with class-validator rules, and let the global ValidationPipe enforce them — auto-400 on bad input, zero validation code in your controllers.
- Building a REST API Assemble the whole tasks resource — thin controller, service with the logic and store, DTOs for input, module for wiring — into full CRUD, throwing built-in HTTP exceptions that auto-map to status codes.
- Guards, Interceptors & Middleware Nest's request pipeline has named building blocks, each with one job: guards decide who gets in, interceptors wrap the handler, pipes validate input, filters shape errors, middleware does Express-style work.
- Testing & Production Use Nest's DI test module to swap mocks for real deps in unit tests, boot the whole app for e2e tests with supertest, centralize config with @nestjs/config, and ship a compiled production build.
- Where to Go Next What you can build now, how NestJS compares to Express and Fastify, the official ecosystem you'll reach for, and one concrete project to carry the tasks API all the way home.