From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Introduction to interceptors - Nest.js Tutorial
From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Introduction to interceptors
Now, we are going to learn about one more important fundamental concept in NestJS, which is called interceptors. Interceptors basically are just like the middleware. As they intercept the request before it even reaches the route handlers, and they can also intercept the response. So it has a direct access to both the request and response. We can definitely say that they are like middleware but with more powerful capabilities. Using interceptors we can modify the request by adding certain data in it or we can validate the request to meet certain criteria and many other similar things like that. All this before it reaches the route handler in fact. The same thing for the responses as well, like caching or error handling, transformations, etc. So an interceptor is what lies between a client and the Nest API endpoint. And we can do anything we want with the request or response before it reaches the destination. Now basically, interceptors are executed after the middleware and guards…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Introduction to interceptors3m
-
(Locked)
Understanding interceptor5m 54s
-
(Locked)
Assignment: Transforming response data4m 42s
-
(Locked)
Assignment: Modifying request headers3m 49s
-
(Locked)
Assignment: Hiding sensitive information5m 50s
-
(Locked)
Exception mapping3m 23s
-
(Locked)
Data validation with interceptor5m 37s
-
(Locked)
Authentication and authorization4m 24s
-
(Locked)
Applying global interceptors2m 39s
-
(Locked)
-
-
-
-
-
-