Which decorator is used to apply middleware to a specific route in NestJS?
@Route()
@UseMiddleware()
@Middleware()
@ApplyMiddleware()
How do you inject a provider from a different module in NestJS?
By creating a new instance of the provider using its constructor.
By using the @Inject() decorator and specifying the provider's class name.
@Inject()
By accessing the global NestJS container.
By importing the module containing the provider into the module where you need it.
When would you choose to create a custom exception filter instead of using a built-in one?
When you need to implement specific error logging or response formatting for unique situations.
When you want to handle all exceptions in a single, centralized location.
When you are working with a database that is not supported by NestJS.
When you need to integrate with an external error monitoring service.
How would you define a route parameter named 'id' in a NestJS route path?
/users/:id
/users/<id>
/users/{id}
/users?id=value
What is the purpose of the @Body() decorator?
@Body()
Accesses query parameters
Accesses the request headers
Accesses the entire request body
Accesses route parameters
Which of the following is NOT a valid scope for a provider in NestJS?
@Scoped()
@Transient()
@Singleton()
@RequestScoped()
Which of these features is NOT a primary advantage of using NestJS?
Provides a command-line interface (CLI) for easy project setup
Encourages code organization through modules and providers
Directly renders dynamic user interfaces in the browser
Leverages TypeScript for improved code structure and maintainability
How do you access the request body in a NestJS controller?
Through the context object
context
Accessing request.data
request.data
Using req.body
req.body
Using the @Body() decorator
Which decorator is used to define a basic GET route in NestJS?
@Get()
@Post()
@Path()
What is the recommended way to create a Service in NestJS?
By annotating a class with @Injectable() and registering it as a provider.
@Injectable()
By defining a class and using it directly.
By using the service keyword.
service
Services are not a concept in NestJS.