What is the purpose of a Model in Mongoose?
To handle user authentication and authorization
To interact with a specific collection in the database based on a defined schema
To create and manage database migrations
To define a database connection string
In the context of NestJS testing, what are 'mocks' primarily used for?
Replacing external dependencies with controlled implementations
Measuring the performance of specific code segments
Automating user interactions with the application's UI
Generating code coverage reports
Which module is essential for implementing JWT authentication in a NestJS application?
@nestjs/jwt
@nestjs/core
@nestjs/passport
@nestjs/common
What is a key benefit of using event subscribers in NestJS?
Enhanced type safety when defining event listeners
Improved performance for handling a large volume of events
Automatic retry mechanisms for failed event handlers
Centralized management and organization of event listeners
How do you activate a custom Guard globally in a NestJS application?
By using the @Global() decorator before the guard class definition.
@Global()
By defining the guard within the main.ts file of your application.
main.ts
By registering the guard in the providers array of the module where it's defined.
providers
By manually adding the guard to each route handler where it's needed.
What is the role of the catch() method in a custom HTTP exception filter?
catch()
It logs the exception to the console.
It determines the appropriate HTTP status code for the exception.
It re-throws the exception to be handled by a global exception filter.
It handles the exception and sends a customized error response.
What is the recommended approach for handling exceptions in a production-ready NestJS application?
Rely solely on the default NestJS error handling mechanism.
Disable exception handling altogether for optimal performance.
Implement only global exception filters for a centralized approach.
Use a combination of global and custom exception filters for a layered approach.
In a NestJS microservice architecture, how do services typically communicate with each other asynchronously?
Direct method calls
Message queues
Shared memory
Database triggers
Which interface does a logging interceptor primarily implement in NestJS to intercept incoming requests and outgoing responses for logging purposes?
NestInterceptor
OnRequestInterceptor
OnResponseInterceptor
LoggingInterceptor
What is the role of the 'transform()' method within a custom Pipe in NestJS?
It determines if the Pipe should be applied globally.
It contains the logic to transform the input data.
It specifies how the Pipe should handle errors.
It defines the metadata associated with the Pipe.