What is the purpose of the @Module() decorator?
@Module()
To mark a class as a database entity.
To define a route handler for a specific HTTP method.
To define a module, which acts as a container for other NestJS components.
To define a unit test case.
How do you inject a provider from a different module in NestJS?
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.
By using the @Inject() decorator and specifying the provider's class name.
@Inject()
Which of these features is NOT a primary advantage of using NestJS?
Leverages TypeScript for improved code structure and maintainability
Directly renders dynamic user interfaces in the browser
Provides a command-line interface (CLI) for easy project setup
Encourages code organization through modules and providers
What is the advantage of using built-in HTTP exception filters in NestJS?
They are primarily used for handling authentication and authorization errors.
They are only applicable for database-related exceptions.
They provide a streamlined way to handle common HTTP errors with predefined responses.
They allow you to bypass the need for exception handling altogether.
Which decorator is used to define a custom exception filter in NestJS?
@Catch()
@Controller()
@Injectable()
Which decorator is used to define a controller in NestJS?
@Component()
When using an Interceptor to modify the response, what is the best way to ensure type safety?
Type checking is not necessary within Interceptors.
Using generics with the NestInterceptor interface.
NestInterceptor
Type casting within the Interceptor.
Disabling type checks within the Interceptor.
How can you transform the data returned from a controller method using an Interceptor?
By using RxJS operators on the Observable returned by next.handle().
next.handle()
By directly modifying the controller method's return value.
By calling a service method within the Interceptor.
By modifying the ctx.body property.
ctx.body
What is the role of the 'main.ts' file in a NestJS project?
Stores environment variables and configuration settings
Defines the application's database schema and models
Contains unit tests for the application's logic
Creates and configures the NestJS application instance
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 contains the application's main configuration and serves as the root module.
It handles routing logic for different API endpoints.
It defines a specific service for a particular business logic.