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.
Understanding interceptor - Nest.js Tutorial
From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Understanding interceptor
Now, let's see how to implement the interceptor and understand the code syntax. To create a new interceptor, I will give the nest CLI command, nest generate ITC, which is short for interceptor. You can also give the whole word that is interceptor. Then I'll give slash interceptors, which is going to be the name of the folder and slash test, which is the interceptor name, hyphen hyphen, no spec. And the file is created. Let me open it. And we get the default boilerplate code for the interceptor. And as you can see, there are a bunch of interfaces imported which are used by the interceptor. So let's break down the syntax and understand it. Starting with the import statements, first we have the call handler interface. This interface represents a handler, a handler that processes the request and produces a response. Then we have the execution context interface, which we already saw in the guards section. So to get the details about the request and response objects in the interceptor, we…
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)
-
-
-
-
-
-