In a NestJS application using CQRS, what is the role of a command handler?
To emit events in response to user actions
To process incoming events and update the application state
To handle errors and exceptions within event listeners
To retrieve data from the database based on a query
Which decorator is used to apply a custom Pipe to a specific parameter in a NestJS controller?
@UsePipes()
@Transform()
@Pipe()
@Injectable()
Which NestJS module is essential for creating TCP-based microservices?
@nestjs/microservices
@nestjs/platform-express
@nestjs/core
@nestjs/common
Which of these is NOT a common method for storing session data in a NestJS application?
Local variable storage
Database storage
File system storage
In-memory storage
What is the primary testing framework used for unit testing in NestJS?
Mocha
Jest
Jasmine
Chai
What decorator is used to register a caching interceptor globally in a NestJS application?
@UseInterceptors(CacheInterceptor)
@GlobalCache()
@GlobalInterceptor(CacheInterceptor)
@Cache()
What is a key benefit of using event subscribers in NestJS?
Automatic retry mechanisms for failed event handlers
Improved performance for handling a large volume of events
Centralized management and organization of event listeners
Enhanced type safety when defining event listeners
What is the purpose of the 'transport' option when creating a NestJS microservice?
Configuring the user interface
Specifying the communication protocol (e.g., TCP, Redis)
Setting the logging level
Defining the database connection
When would you create a custom Guard in NestJS instead of relying on built-in solutions?
When you need to perform standard JWT (JSON Web Token) authentication.
When you need to implement authorization logic tailored to your application's specific requirements, which might involve checking for custom permissions or conditions.
When you want to handle database migrations automatically.
When you need to send emails after a user signs up.
What is the difference between HttpException and a custom exception class in NestJS?
HttpException
HttpException is used for generic HTTP errors, while custom exceptions represent specific business logic errors.
HttpException must be caught by custom exception filters, while custom exceptions are handled automatically.
There is no practical difference; both can be used interchangeably for error handling.
HttpException is deprecated and should always be replaced with custom exception classes.