What is the role of the app.module.ts file in a NestJS application?
app.module.ts
It defines a single controller for handling HTTP requests.
It handles routing logic for different API endpoints.
It defines a specific service for a particular business logic.
It contains the application's main configuration and serves as the root module.
Which design pattern heavily influences the architecture of NestJS?
Observer
Singleton
Factory
Dependency Injection
What is the purpose of the @Module() decorator?
@Module()
To define a module, which acts as a container for other NestJS components.
To mark a class as a database entity.
To define a route handler for a specific HTTP method.
To define a unit test case.
What are the building blocks of a NestJS application called?
Services
Modules
Components
Controllers
How would you define a route parameter named 'id' in a NestJS route path?
/users/:id
/users?id=value
/users/<id>
/users/{id}
How can you transform the data returned from a controller method using an Interceptor?
By modifying the ctx.body property.
ctx.body
By using RxJS operators on the Observable returned by next.handle().
next.handle()
By calling a service method within the Interceptor.
By directly modifying the controller method's return value.
Which decorator is used to apply middleware to a specific route in NestJS?
@Route()
@UseMiddleware()
@ApplyMiddleware()
@Middleware()
What is the primary purpose of using Interceptors in NestJS?
To create reusable UI components.
To define routes for API endpoints.
To handle database queries.
To intercept and modify incoming requests or outgoing responses.
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.
What decorator is used for handling HTTP requests meant for updating resources?
@Put()
@Post()
@Delete()
@Patch()