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.
Assignment: Hiding sensitive information - Nest.js Tutorial
From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Assignment: Hiding sensitive information
Assume a scenario where we have a NestJS app with an endpoint that fetches the user data from a database. We want to create an interceptor in such a way that it transforms the user data to hide or remove sensitive information, for example, password before sending the response back to the client. And this is what we are going to implement in this assignment. So let's begin. I'll create a user service file first. So let me give the command nest generate service slash services slash user hyphen hyphen no spec. I'll open the service file. And here I will create a users array object by giving private users. And in this object, I'll define a few properties like id 1, name user A, e-mail, I'll give user A at example.com and password I'll keep secret key 1. Similarly, I'll create two more objects that is user B and user C. Now I'll define a method to find the user. It will take an ID as an argument which is of type number and in the return statement I'll give this dot users dot find user user…
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)
-
-
-
-
-
-