What is the difference between HttpException and a custom exception class in NestJS?
HttpException
HttpException must be caught by custom exception filters, while custom exceptions are handled automatically.
HttpException is deprecated and should always be replaced with custom exception classes.
There is no practical difference; both can be used interchangeably for error handling.
HttpException is used for generic HTTP errors, while custom exceptions represent specific business logic errors.
In Mongoose, what is a Schema?
A representation of a database connection
A method for handling HTTP requests
A configuration file for a NestJS application
A definition of the structure and data types for documents in a collection
What is the role of a Repository in TypeORM?
To define database tables
To handle user authentication
To provide methods for interacting with a specific entity
To manage database migrations
How do you register a global exception filter in NestJS?
By using the @Catch() decorator on the global filter class.
@Catch()
By using the useGlobalFilters() method in the main.ts file.
useGlobalFilters()
main.ts
By adding the global filter class to the providers array in the module definition.
providers
By extending the base ExceptionFilter class and annotating it with the @Global() decorator.
ExceptionFilter
@Global()
Which testing type provides the most comprehensive coverage by simulating real user interactions with a running NestJS application?
Integration Testing
Unit Testing
End-to-End (E2E) Testing
Regression Testing
What is the purpose of the 'ParseIntPipe' in NestJS?
To validate the data type of an input parameter.
To convert a string value to a Boolean.
To transform a numeric string into an integer.
To parse an object into a JSON string.
When designing a microservice using NestJS, what is a recommended practice for ensuring service discovery?
Manually updating configuration files
Using a service registry (e.g., Consul, etcd)
Relying on client-side load balancing
Hardcoding service addresses
Which NestJS module is essential for creating TCP-based microservices?
@nestjs/microservices
@nestjs/common
@nestjs/core
@nestjs/platform-express
What is a key benefit of using event subscribers in NestJS?
Improved performance for handling a large volume of events
Enhanced type safety when defining event listeners
Centralized management and organization of event listeners
Automatic retry mechanisms for failed event handlers
What object in the intercept() method of a transformation interceptor allows you to modify the response stream?
intercept()
context.switchToHttp().getResponse()
context.getRequest()
context.switchToWs().getClient()
context.getNext()