What is the primary function of middleware in NestJS?
To handle database operations.
To render dynamic views on the server.
To define API routes.
To intercept and modify incoming requests and outgoing responses.
When using @Inject(), what should you provide as the argument?
@Inject()
The class name of the dependency.
The injection token of the dependency.
The string 'inject'.
An instance of the dependency.
Which decorator is used to define an Interceptor class in NestJS?
@Controller()
@Injectable()
@Interceptor()
@Module()
What is the recommended way to create a Service in NestJS?
By using the service keyword.
service
Services are not a concept in NestJS.
By defining a class and using it directly.
By annotating a class with @Injectable() and registering it as a provider.
What is the default scope of a provider in NestJS?
Request-scoped
Singleton
Transient
Module-scoped
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 are working with a database that is not supported by NestJS.
When you want to handle all exceptions in a single, centralized location.
When you need to integrate with an external error monitoring service.
What is the role of Providers in NestJS?
To handle data persistence.
To render UI elements.
To provide dependencies that can be injected into other components like controllers or services.
To define the application's entry point.
What is the primary function of a module in NestJS?
To handle HTTP requests and responses.
To interact with databases and external APIs.
To organize code into related units and manage dependencies.
Which decorator is used to apply middleware to a specific route in NestJS?
@Middleware()
@ApplyMiddleware()
@Route()
@UseMiddleware()
What is the core purpose of NestJS?
Managing and interacting with databases directly
Building interactive front-end web applications
Developing efficient and scalable server-side applications
Automating code deployment and server configuration