What is the purpose of a Model in Mongoose?
To create and manage database migrations
To interact with a specific collection in the database based on a defined schema
To handle user authentication and authorization
To define a database connection string
What object in the intercept() method of a transformation interceptor allows you to modify the response stream?
intercept()
context.switchToWs().getClient()
context.getNext()
context.switchToHttp().getResponse()
context.getRequest()
How can you apply a transformation interceptor to a specific method in a controller in NestJS?
By extending the BaseController class and applying the interceptor in the constructor
BaseController
By using the @Transform() decorator above the controller class
@Transform()
By registering the interceptor globally in the app.module.ts file
app.module.ts
By using the @UseInterceptors() decorator at the method level
@UseInterceptors()
What is the recommended approach to unit test a custom Guard in NestJS?
By setting up a complete end-to-end testing environment that interacts with real databases and services.
By manually triggering API requests using tools like Postman and observing the responses.
By mocking external dependencies like database calls or HTTP requests, focusing on testing the Guard's logic in isolation.
By relying solely on console logs within the Guard's code to verify its behavior.
Which of the following transport mechanisms is well-suited for building highly scalable and real-time NestJS microservices?
Redis
File system
HTTP
Email
What is the primary function of a Pipe in NestJS?
To transform input data into the desired format.
To handle database queries and operations.
To manage dependency injection within the application.
To define middleware for routing HTTP requests.
What is the role of a Repository in TypeORM?
To handle user authentication
To provide methods for interacting with a specific entity
To manage database migrations
To define database tables
How do you register a global exception filter in NestJS?
By adding the global filter class to the providers array in the module definition.
providers
By using the useGlobalFilters() method in the main.ts file.
useGlobalFilters()
main.ts
By extending the base ExceptionFilter class and annotating it with the @Global() decorator.
ExceptionFilter
@Global()
By using the @Catch() decorator on the global filter class.
@Catch()
What is the primary purpose of a Guard in NestJS?
To define the structure of a request body.
To control access to routes or resources based on certain conditions.
To render HTML templates on the server.
To handle database interactions.
What is the purpose of the @nestjs/testing package in NestJS?
@nestjs/testing
Offers tools for performance profiling and optimization of NestJS code
Facilitates the deployment of NestJS applications to various cloud platforms
Provides utilities and helpers specifically designed for testing NestJS applications
Enables integration with external continuous integration and delivery (CI/CD) pipelines