How do you define an event listener in a NestJS service?
By implementing the EventEmitter interface
EventEmitter
By injecting the EventEmitter and manually subscribing to events
Using the @Listen() decorator on a service method
@Listen()
Using the @OnApplicationBootstrap() lifecycle hook
@OnApplicationBootstrap()
What is the role of a Repository in TypeORM?
To provide methods for interacting with a specific entity
To define database tables
To handle user authentication
To manage database migrations
Which NestJS module is essential for working with event emitters and listeners?
@nestjs/core
@nestjs/platform-express
@nestjs/common
@nestjs/event-emitter
Which of the following transport mechanisms is well-suited for building highly scalable and real-time NestJS microservices?
File system
Redis
Email
HTTP
What is the recommended approach to unit test a custom Guard in NestJS?
By mocking external dependencies like database calls or HTTP requests, focusing on testing the Guard's logic in isolation.
By setting up a complete end-to-end testing environment that interacts with real databases and services.
By relying solely on console logs within the Guard's code to verify its behavior.
By manually triggering API requests using tools like Postman and observing the responses.
How does the CQRS pattern improve the design of event-driven systems?
By enforcing synchronous communication between components
By eliminating the need for event listeners
By separating read and write operations for better performance and scalability
By simplifying the handling of complex events
What is the primary purpose of a Guard in NestJS?
To define the structure of a request body.
To render HTML templates on the server.
To handle database interactions.
To control access to routes or resources based on certain conditions.
Can you have both global and custom HTTP exception filters in a NestJS application?
No, NestJS only allows you to define either global or custom exception filters, not both.
Yes, but you need to explicitly specify the order in which they should be executed.
No, global exception filters take precedence and override any custom filters.
Yes, but custom filters will only handle exceptions not caught by global filters.
Which testing type provides the most comprehensive coverage by simulating real user interactions with a running NestJS application?
Integration Testing
Unit Testing
Regression Testing
End-to-End (E2E) Testing
Which interface should a class implement to function as a Guard in NestJS?
IInjectable
IGuardProvider
ICanActivate
IAuthorizationHandler