Recall & Review
beginner
What is a Logging Interceptor in NestJS?
A Logging Interceptor in NestJS is a special piece of code that runs before and after a request to log important information like request details and response time. It helps track what happens inside the app.
Click to reveal answer
beginner
How does a Logging Interceptor improve debugging?
It records details about requests and responses, such as method names, execution time, and errors. This makes it easier to find and fix problems by showing what happened step-by-step.
Click to reveal answer
intermediate
Which NestJS interface must a Logging Interceptor implement?
It must implement the NestInterceptor interface, which requires a method called intercept to handle the logging logic.
Click to reveal answer
intermediate
What method inside the Logging Interceptor captures the request and response?
The intercept method captures the request before it reaches the handler and the response after the handler finishes, allowing logging at both points.
Click to reveal answer
advanced
Why use RxJS operators like tap() inside a Logging Interceptor?
RxJS tap() lets you run code when the response is ready without changing the response itself. This is perfect for logging response details after the request completes.
Click to reveal answer
What is the main purpose of a Logging Interceptor in NestJS?
✗ Incorrect
Logging Interceptors are designed to log details about requests and responses to help with monitoring and debugging.
Which method must be implemented in a NestJS interceptor?
✗ Incorrect
The intercept() method is required by the NestInterceptor interface to define the interceptor's behavior.
What does the RxJS tap() operator do in a Logging Interceptor?
✗ Incorrect
tap() allows running code such as logging when the response is ready, without altering the response stream.
Where in the request lifecycle does a Logging Interceptor run?
✗ Incorrect
Logging Interceptors run before the handler to capture request info and after to capture response info.
Which NestJS decorator is used to apply an interceptor to a controller or route?
✗ Incorrect
@UseInterceptors() applies interceptors like Logging Interceptor to controllers or routes.
Explain how a Logging Interceptor works in NestJS and why it is useful.
Think about what happens when a request comes in and how logging helps.
You got /4 concepts.
Describe how RxJS tap() is used inside a Logging Interceptor.
Consider how to log data without affecting the flow.
You got /4 concepts.