How are controllers related to modules in NestJS?
Controllers are defined within modules, and their scope is limited to that module.
Controllers and modules are unrelated concepts in NestJS.
Modules are defined within controllers.
Controllers exist independently of modules.
When would you choose to create a custom exception filter instead of using a built-in one?
When you want to handle all exceptions in a single, centralized location.
When you need to implement specific error logging or response formatting for unique situations.
When you are working with a database that is not supported by NestJS.
When you need to integrate with an external error monitoring service.
Which of the following best describes NestJS?
A cloud computing platform for deploying and scaling applications
A server-side framework for building efficient and scalable applications
A front-end framework for building user interfaces
A database management system for storing application data
What is the recommended way to access query parameters in a NestJS controller?
Through the context.request object
context.request
Using req.query
req.query
Accessing params.query
params.query
Using the @Query() decorator
@Query()
How do you define middleware in NestJS?
By using the @Middleware() decorator on a class.
@Middleware()
By configuring middleware directly in the main.ts file.
main.ts
By creating a class that implements the CanActivate interface.
CanActivate
By creating a function with a specific signature.
What is the primary function of middleware in NestJS?
To define API routes.
To intercept and modify incoming requests and outgoing responses.
To render dynamic views on the server.
To handle database operations.
Which decorator is used to define a controller in NestJS?
@Component()
@Module()
@Injectable()
@Controller()
How can you transform the data returned from a controller method using an Interceptor?
By calling a service method within the Interceptor.
By modifying the ctx.body property.
ctx.body
By directly modifying the controller method's return value.
By using RxJS operators on the Observable returned by next.handle().
next.handle()
Which of the following is NOT a valid HTTP method for defining routes in NestJS?
PUT
PATCH
DELETE
RENDER
What is the difference between a provider and a service in NestJS?
Providers are decorated with @Injectable(), while services are decorated with @Service().
Providers are used for database operations, while services handle business logic.
Providers are classes that can be injected as dependencies, while a service is a specific type of provider with business logic.
Providers and services are essentially the same thing, with no real distinction.