Which decorator is used to define a custom exception filter in NestJS?
@Module()
@Catch()
@Injectable()
@Controller()
What is the recommended way to access query parameters in a NestJS controller?
Accessing params.query
params.query
Through the context.request object
context.request
Using req.query
req.query
Using the @Query() decorator
@Query()
What is the purpose of Providers in NestJS?
To define database models and interact with the database
To handle routing and HTTP requests
To render the user interface and manage view templates
To provide reusable logic and services that can be injected into other components
Which design pattern heavily influences the architecture of NestJS?
Observer
Dependency Injection
Factory
Singleton
What is the purpose of the imports array in a NestJS module definition?
imports
To import external JavaScript libraries.
To include providers that are specific to the module.
To define the routes handled by the module.
To import other modules, making their exported components available within the current module.
Can a Controller access a Service's methods in NestJS?
Yes, by injecting the Service into the Controller's constructor.
No, Controllers and Services are completely isolated.
Yes, by using static methods of the Service.
Only if the Controller and Service are defined in the same module.
What is the purpose of the return statement in a NestJS controller method?
return
To define the route path
To handle errors within the route
To send the response to the client
To specify middleware for the route
Can you apply multiple middleware to a single route in NestJS?
Yes, but you need to create a separate middleware class that combines the functionality of others.
Yes, by using the @MultipleMiddleware() decorator.
@MultipleMiddleware()
No, only one middleware can be applied to a route.
Yes, by passing multiple middleware classes or functions to the @UseMiddleware() decorator.
@UseMiddleware()
What is the role of the 'HttpException' class in NestJS exception handling?
It's a decorator for marking methods that handle HTTP exceptions.
It's an interface for defining the structure of exception objects.
It's a base class for creating custom exceptions with HTTP status codes.
It's a module for configuring global exception handling.
What is the purpose of the @Res() decorator in NestJS?
@Res()
To access route parameters
To define a new route
To directly interact with the response object
To handle asynchronous operations