What is the primary programming language used for developing NestJS applications?
Python
JavaScript
C#
Java
What is the role of Providers in NestJS?
To handle data persistence.
To define the application's entry point.
To provide dependencies that can be injected into other components like controllers or services.
To render UI elements.
How does Dependency Injection work in NestJS?
Dependency Injection is not supported in NestJS.
NestJS automatically resolves and injects dependencies based on constructor parameters.
Dependencies are fetched from a global configuration file.
Dependencies are manually created and passed around.
When would you choose to create a custom exception filter instead of using a built-in one?
When you need to integrate with an external error monitoring service.
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.
What interface must a class implement to act as an Interceptor in NestJS?
RequestInterceptor
ResponseInterceptor
HttpInterceptor
NestInterceptor
How do you apply an exception filter globally in a NestJS application?
By adding the filter class to the providers array of a module.
providers
By decorating the controller class with the filter.
By manually invoking the filter within each controller method.
By using the useGlobalFilters() method in the app.module.ts file.
useGlobalFilters()
app.module.ts
What is the purpose of the useFactory property in a FactoryProvider?
useFactory
FactoryProvider
To configure the lifecycle hooks of the provider.
To provide a static value for the provider.
To define a function that creates and returns an instance of the provider.
To specify the class that the factory function should return.
What is the command to install the NestJS CLI globally?
npm install -g @nestjs/cli
npm install nestjs
install -g nestjs
yarn global add nestjs
When using an Interceptor to modify the response, what is the best way to ensure type safety?
Disabling type checks within the Interceptor.
Using generics with the NestInterceptor interface.
Type checking is not necessary within Interceptors.
Type casting within the Interceptor.
What is the difference between a provider and a service in NestJS?
Providers are used for database operations, while services handle business logic.
Providers and services are essentially the same thing, with no real distinction.
Providers are decorated with @Injectable(), while services are decorated with @Service().
Providers are classes that can be injected as dependencies, while a service is a specific type of provider with business logic.