NestJS Research & Evidence-Based Practice 4 — Questions and Answers
Question 1: Based on NestJS profiling research, which built-in module enables logging of route resolution time and middleware execution for performance analysis?
- LoggerModule
- ProfilingModule
- NestFactory with logger option
- DevtoolsModule (Correct answer)
Correct answer: DevtoolsModule
DevtoolsModule (@nestjs/devtools-integration) integrates with the NestJS Devtools browser app to visualize and profile application internals.
Question 2: Evidence from NestJS documentation shows that which configuration approach is recommended for environment-specific settings like database URLs?
- Hardcoding values in service files
- Using ConfigModule with .env files via @nestjs/config (Correct answer)
- Reading process.env directly in every file
- Storing config in a JSON file imported statically
Correct answer: Using ConfigModule with .env files via @nestjs/config
ConfigModule from @nestjs/config loads environment variables from .env files and makes them available via ConfigService throughout the application.
Question 3: Research into NestJS microservices reveals that which transport layer uses Redis pub/sub for message passing between services?
- TCP
- MQTT
- Redis (Correct answer)
- NATS
Correct answer: Redis
The Redis transport in NestJS microservices uses Redis pub/sub to route messages between microservice instances.
Question 4: When analyzing NestJS OpenAPI documentation practices, which decorator applied to a DTO property describes it in the generated Swagger UI?
- @ApiParam()
- @ApiProperty() (Correct answer)
- @ApiBody()
- @ApiResponse()
Correct answer: @ApiProperty()
@ApiProperty() from @nestjs/swagger annotates DTO class properties so they appear with correct type information in Swagger UI.
Question 5: Based on benchmark evidence, which NestJS technique reduces database query overhead by batching multiple related queries within a single request?
- Eager loading with JOIN
- DataLoader pattern for N+1 resolution (Correct answer)
- Query caching with Redis
- Connection pooling with pg-pool
Correct answer: DataLoader pattern for N+1 resolution
The DataLoader pattern batches and caches database lookups within a single request cycle, preventing N+1 query problems especially in GraphQL resolvers.
Question 6: Research shows that NestJS supports which built-in pipe for automatically transforming incoming request data to match a DTO class type?
- ValidationPipe with transform: true (Correct answer)
- ParseIntPipe
- DefaultValuePipe
- ParseBoolPipe
Correct answer: ValidationPipe with transform: true
ValidationPipe with the transform option set to true automatically transforms plain request objects into instances of the target DTO class.
Question 7: Based on NestJS architectural research, which pattern is recommended when a module needs to share a service with other modules?
- Import the service file directly
- Use global providers only
- Export the service from the providing module and import the module (Correct answer)
- Duplicate the service in every module
Correct answer: Export the service from the providing module and import the module
The correct pattern is to add the service to the exports array of its module; consuming modules then import that module to access the service.
Based on NestJS profiling research, which built-in module enables logging of route resolution time and middleware execution for performance analysis?