NestJS is a progressive Node.js framework for building efficient, scalable server-side applications using TypeScript (or JavaScript), combining elements from Object-Oriented Programming, Functional Programming, and Reactive Programming. Built with Express (or optionally Fastify) under the hood, it provides an out-of-the-box application architecture inspired by Angular, featuring dependency injection, modular organization, and decorator-based programming. What makes NestJS stand out is its first-class TypeScript support combined with a rich ecosystem of official modules for authentication, GraphQL, WebSockets, microservices, and more—letting you build production-ready backends without assembling dozens of libraries yourself.
What This Cheat Sheet Covers
This topic spans 23 focused tables and 111 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Core Building Blocks
Every NestJS app is assembled from a handful of primitives—modules wire features together, controllers receive requests, and providers hold your logic, all stitched up by the dependency injection container. Master these and the rest of the framework clicks into place, because almost everything later in this sheet is just one of these pieces wearing a different decorator.
| Pattern | Example | Description |
|---|---|---|
({ imports: [UserModule], controllers: [AppController], providers: [AppService],})export class AppModule {} | • Organizes application structure • groups related controllers and providers • controls what is exported/imported between modules | |
('users')export class UserController { (':id') findOne(('id') id: string) {}} | • Handles incoming HTTP requests and returns responses • routes are defined via decorators like @Get(), @Post()• route parameters extracted with @Param(), query strings with @Query(), request body with @Body(). | |
()export class UserService { findAll() { return []; }} | • Business logic layer • marked with @Injectable() for dependency injection• typically injected into controllers or other services • can be repositories, factories, helpers, etc |