What is the primary purpose of exception handling in a NestJS backend application?
To enforce strict data typing in controller methods.
To define middleware functions for request-response cycles.
To handle database migrations and schema changes.
To gracefully handle and respond to unexpected errors during request processing.
Which interface does a custom exception filter in NestJS need to implement?
ExceptionFilter
Injectable
CanActivate
HttpException
Which decorator is used to mark a class as a provider in NestJS?
@Service()
@Controller()
@Module()
@Injectable()
What is a common use case for middleware in NestJS?
Generating database queries.
Implementing authentication and authorization logic.
Defining API endpoints.
Rendering HTML templates.
What is a potential drawback of using singleton providers excessively in a large application?
All of the above.
Increased memory usage due to persistent instances.
Slower application startup time.
Difficulty in testing individual components.
When using an Interceptor to modify the response, what is the best way to ensure type safety?
Type casting within the Interceptor.
Using generics with the NestInterceptor interface.
NestInterceptor
Disabling type checks within the Interceptor.
Type checking is not necessary within Interceptors.
What is the command to install the NestJS CLI globally?
yarn global add nestjs
npm install nestjs
install -g nestjs
npm install -g @nestjs/cli
What design pattern does NestJS heavily rely on for structuring code?
Singleton
Dependency Injection
Observer
Factory Method
Which decorator is used to define a basic GET route in NestJS?
@Route()
@Get()
@Path()
@Post()
How would you define a route parameter named 'id' in a NestJS route path?
/users?id=value
/users/{id}
/users/:id
/users/<id>