Files
main.tsmain
What you'll learn
- Implement NestInterceptor and use the ExecutionContext to name the handler and set a response header before it runs
- Transform response bodies with the map operator, and explain why a thrown exception is not mapped
- Bind interceptors to a controller with @UseInterceptors and to the application with useGlobalInterceptors
Press Run tests to start the app. Its log appears here.Graded endpoints
The body is wrapped in { data }, and the header names the class and the handler
The status is untouched by map; the body is wrapped
Wrapped as well
An exception is not a value on the stream: map never runs and Nest's error body is kept, but the header is there because the interceptor ran before the handler threw