NestJS Interview Questions & Answers
Prepare for NestJS technical interviews with 100 curated questions and answers — from fundamentals to Tech Lead. Modules, DI, guards, pipes, and Nest architecture. Each question includes a short interview answer, detailed explanation, examples, tips, and common mistakes.
NestJS interview topics
Jump into a category — each bank is independent and interview-focused.
Modules
6 NestJS questions
Controllers
6 NestJS questions
Providers
6 NestJS questions
Dependency Injection
6 NestJS questions
Middleware
5 NestJS questions
Guards
6 NestJS questions
Pipes
6 NestJS questions
Interceptors
6 NestJS questions
Exception Filters
6 NestJS questions
DTOs
5 NestJS questions
Validation
6 NestJS questions
Authentication
6 NestJS questions
Authorization
6 NestJS questions
ORM Concepts
6 NestJS questions
Microservices
6 NestJS questions
Testing
6 NestJS questions
Architecture
6 NestJS questions
All NestJS interview questions
Modules interview questions
View categoryWhat is a NestJS module and why does it exist?
freshimports vs exports vs providers in @Module — differences?
juniorWhat are global modules and when are they appropriate?
juniorDynamic modules (forRoot/forRootAsync) — why?
midFeature module vs shared module vs core module — how do you split?
seniorLead: structure Nest modules for a multi-team monorepo API.
seniorControllers interview questions
View categoryWhat is a Nest controller responsible for?
freshHow do @Param, @Query, @Body, and @Headers work together?
juniorVersioning APIs in Nest — approaches?
juniorWhen should logic leave the controller?
midScenario: controller returns entities with password hashes. Fix?
seniorLead: conventions for public vs internal Nest controllers?
seniorProviders interview questions
View categoryWhat counts as a provider in Nest?
freshuseFactory vs useClass vs useValue — when?
juniorWhat is a custom injection token and why use string/symbol tokens?
juniorTransient vs request vs singleton scope — trade-offs?
midDebugging: Nest says provider not found at runtime.
seniorLead: provider design for ports-and-adapters in Nest?
seniorDependency Injection interview questions
View categoryHow does Nest's DI container resolve dependencies?
freshWhy forwardRef exists and when it's a smell?
juniorOptional dependencies with @Optional() — use cases?
juniorConstructor injection vs @Inject() property injection?
midScenario: two implementations of the same interface for A/B payments.
seniorLead: how do you keep DI graphs understandable at 200+ providers?
seniorMiddleware interview questions
View categoryGuards interview questions
View categoryWhat does a Nest Guard do?
freshHow do you build role-based guards with custom decorators?
juniorGuard order and multiple guards — behavior?
juniorGuards vs middleware for API keys?
midScenario: public health route blocked by global AuthGuard.
seniorLead: authorization model beyond role strings in Nest?
seniorPipes interview questions
View categoryWhat are Nest pipes used for?
freshValidationPipe with whitelist/forbidNonWhitelisted — why?
juniorTransform pipes vs validate-only — examples?
midWhere should pipes be registered: global vs param?
midDebugging: ValidationPipe not running on a nested DTO.
seniorLead: standardize input validation across many Nest services?
leadInterceptors interview questions
View categoryException Filters interview questions
View categoryWhat does an exception filter do?
freshHttpException vs domain errors — mapping strategy?
juniorBuilt-in vs custom filters — when custom?
midOrder of filters and @Catch specificity?
midDebugging: errors return Nest's default JSON in production unexpectedly.
seniorLead: unify error contracts across Nest and non-Nest services?
leadDTOs interview questions
View categoryValidation interview questions
View categoryHow does ValidationPipe + class-validator validate bodies?
freshValidate nested arrays of objects — requirements?
juniorCustom validators — when?
midZod/io-ts vs class-validator in Nest — trade-offs?
midScenario: validation passes but business rule fails later.
seniorLead: org-wide validation standards for Nest APIs?
leadAuthentication interview questions
View categoryAuthorization interview questions
View categoryORM Concepts interview questions
View categoryTypeORM vs Prisma with Nest — practical trade-offs?
freshWhere should repositories live in Nest modules?
juniorHow do you handle transactions in Nest services?
midN+1 queries in Nest resolvers/services — prevention?
midMigrations in production Nest apps — best practices?
seniorLead: multi-DB or CQRS read models with Nest?
leadMicroservices interview questions
View categoryHow do Nest microservices differ from HTTP controllers?
freshRequest-response vs event patterns in Nest microservices?
juniorWhy is idempotency critical for Kafka/Rabbit consumers?
midgRPC with Nest — when prefer it?
seniorDebugging: Nest microservice hangs waiting for response.
seniorLead: when NOT to split a Nest monolith into microservices?
leadTesting interview questions
View categoryWhat is TestingModule in Nest?
juniorUnit test a service with mocked repo — pattern?
juniore2e testing Nest HTTP apps — approach?
midHow do you test guards/pipes/interceptors in isolation?
seniorScenario: flaky e2e due to module singletons holding state.
seniorLead: testing strategy pyramid for a large Nest codebase?
leadArchitecture interview questions
View categoryIs Nest only for microservices? What default architecture fits most teams?
juniorClean/hexagonal architecture mapping onto Nest?
juniorConfig management best practices in Nest?
midScenario: circular dependency between OrdersModule and UsersModule.
seniorHow do you approach background jobs in Nest apps?
seniorLead: evolve a Nest monolith toward service extraction.
lead