NestJS Cheat Sheet 2026
The 30 highest-yield NestJS facts, distilled from real exam questions. Print it, save it as a PDF, or study it here — free, no sign-up.
60 questions
75 min time limit
70.00% to pass
- How do you make a NestJS module available globally without importing it in every other module? → Add @Global() decorator to the module class
- What does enabling `strict mode` in NestJS's ValidationPipe do? → Throws on any unrecognized property in the request body
- Which built-in NestJS pipe validates and strips non-whitelisted properties from a DTO? → ValidationPipe
- What are the capabilities of a module described as? → A collection of closely related capabilities
- How do you apply a pipe globally to all routes in NestJS? → Use app.useGlobalPipes() in main.ts
- Based on evidence from NestJS documentation, which Jest configuration option is set in jest.config.js to map TypeScript path aliases in test files? → moduleNameMapper
- A NestJS app's database queries slow down due to N+1 problems in a TypeORM relation. What resolves this without a full ORM rewrite? → Use QueryBuilder with explicit leftJoinAndSelect to load relations in a single query
- A NestJS app stores user sessions in memory. What availability risk does this introduce in a horizontally scaled deployment? → Sessions are node-local, so users hitting different instances lose their session state
- In NestJS, what is the purpose of the ConfigModule? → To load and expose environment variables application-wide
- What is the purpose of the @nestjs/testing package's `overrideGuard` method? → To replace a guard with a custom test-only implementation
- Which built-in NestJS module provides configuration management and environment variables? → @nestjs/config
- Which decorator is used to define a NestJS middleware class? → @Injectable()
- Which file is the entry point of a NestJS application created by the CLI? → main.ts
- Which built-in NestJS pipe validates and transforms incoming request data against a DTO class? → ValidationPipe
- When analyzing NestJS OpenAPI documentation practices, which decorator applied to a DTO property describes it in the generated Swagger UI? → @ApiProperty()
- What is the importance of data security in NestJS digital applications? → Protecting sensitive information from unauthorized access, breaches, and loss is essential
- How do you make a single route publicly accessible when JWT auth is applied globally in NestJS? → Use a custom @Public() decorator combined with a reflector check in the guard
- Which interface must a NestJS Guard implement? → CanActivate
- Which database strategy is recommended for NestJS integration tests that need a real database connection without polluting production data? → Using an in-memory SQLite instance or a dedicated test database
- What does NestJS support? → GraphQL and WebSockets
- When writing an E2E test with Supertest in NestJS, which method initializes the application before the test suite runs? → app.init()
- Which decorator in @nestjs/swagger marks a DTO property as required in the generated API schema? → @ApiProperty({ required: true })
- What does the @Query() decorator extract from a request? → Query string parameters (?key=value)
- A DevOps stakeholder asks how to health-check the NestJS service. Which package provides a ready-made /health endpoint? → @nestjs/terminus
- Which method must be called after `Test.createTestingModule()` to finalize the module for use in tests? → .compile()
- What is the role of the `AppModule` in a NestJS application? → It serves as the root module that bootstraps the entire application
- What is the purpose of ClientProxy in NestJS microservices? → To send messages and emit events to a microservice from a client application
- What is the purpose of Guards in NestJS? → To determine whether a request should be handled by the route handler (authorization)
- Which NestJS health-check library integrates with @nestjs/terminus to verify database connectivity as part of a readiness probe? → TypeOrmHealthIndicator from @nestjs/terminus
- A NestJS application processes file uploads. What risk is introduced if uploaded file types and sizes are not validated? → Attackers can upload malicious executables or exhaust disk/memory with oversized files
Turn these facts into recall:
Was this helpful?