How are controllers related to modules in NestJS?
Controllers and modules are unrelated concepts in NestJS.
Modules are defined within controllers.
Controllers exist independently of modules.
Controllers are defined within modules, and their scope is limited to that module.
What is the purpose of the @Body() decorator?
@Body()
Accesses query parameters
Accesses the entire request body
Accesses route parameters
Accesses the request headers
How do you access query parameters in a NestJS controller method?
Using @Query()
@Query()
Using @Headers()
@Headers()
Using @Param()
@Param()
Using @Body()
What is the role of the next() function in NestJS middleware?
next()
To send a response back to the client.
To terminate the request-response cycle.
To log information about the request.
To pass control to the next middleware in the stack or the route handler.
How does Dependency Injection work in NestJS?
Dependency Injection is not supported in NestJS.
Dependencies are manually created and passed around.
Dependencies are fetched from a global configuration file.
NestJS automatically resolves and injects dependencies based on constructor parameters.
What is the purpose of the return statement in a NestJS controller method?
return
To specify middleware for the route
To send the response to the client
To define the route path
To handle errors within the route
Which of the following is NOT a valid HTTP method for defining routes in NestJS?
PUT
DELETE
RENDER
PATCH
What is the role of CallHandler in the intercept method of an Interceptor?
CallHandler
intercept
It provides access to the dependency injection container.
It represents the next Interceptor in the chain or the route handler itself.
It provides utility methods for transforming the request object.
It handles errors thrown within the Interceptor.
What are the building blocks of a NestJS application called?
Modules
Services
Components
Controllers
How do you inject a provider from a different module in NestJS?
By using the @Inject() decorator and specifying the provider's class name.
@Inject()
By creating a new instance of the provider using its constructor.
By importing the module containing the provider into the module where you need it.
By accessing the global NestJS container.