What is the purpose of the @Res() decorator in NestJS?
@Res()
To directly interact with the response object
To define a new route
To handle asynchronous operations
To access route parameters
What is the core purpose of NestJS?
Automating code deployment and server configuration
Building interactive front-end web applications
Developing efficient and scalable server-side applications
Managing and interacting with databases directly
How can you access the currently logged-in user within your middleware in NestJS?
By querying the database directly within the middleware.
By injecting the Request object into the middleware function.
Request
By accessing the req.user object, assuming you have an authentication middleware set up.
req.user
By using the user property of the Response object.
user
Response
How do you access the request body in a NestJS controller?
Accessing request.data
request.data
Using the @Body() decorator
@Body()
Using req.body
req.body
Through the context object
context
How do you apply an exception filter globally in a NestJS application?
By decorating the controller class with the filter.
By manually invoking the filter within each controller method.
By adding the filter class to the providers array of a module.
providers
By using the useGlobalFilters() method in the app.module.ts file.
useGlobalFilters()
app.module.ts
When using an Interceptor to modify the response, what is the best way to ensure type safety?
Using generics with the NestInterceptor interface.
NestInterceptor
Type checking is not necessary within Interceptors.
Disabling type checks within the Interceptor.
Type casting within the Interceptor.
What is the role of the app.module.ts file in a NestJS application?
It handles routing logic for different API endpoints.
It contains the application's main configuration and serves as the root module.
It defines a specific service for a particular business logic.
It defines a single controller for handling HTTP requests.
Inside an Interceptor's intercept method, what object allows you to modify the response?
intercept
ctx.response
next.handle()
interceptor.transform()
ctx.request
What is the recommended way to create a Service in NestJS?
Services are not a concept 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
What is a potential drawback of using singleton providers excessively in a large application?
Difficulty in testing individual components.
Slower application startup time.
Increased memory usage due to persistent instances.
All of the above.