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, 101 flashcards. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
A jump-to index of every table row in this cheat sheet.
An interactive map of every table and concept in this topic.
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 | ||
constructor( private readonly userService: UserService) {} | • Container automatically resolves and injects dependencies via constructor parameters • reduces coupling and improves testability • NestJS uses IoC container under the hood | ||
static forRoot(options: ModuleOptions): DynamicModule { return { module: ConfigModule, providers: [...] };} | • Module that accepts runtime configuration • common pattern for reusable libraries • typically provides forRoot() or forRootAsync() static methods | ||
()({ providers: [LoggerService], exports: [LoggerService]})export class LoggerModule {} | • Decorated with @Global()• exports are available everywhere without importing the module • use sparingly to avoid hidden dependencies |