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.
Implementing global pipes - Nest.js Tutorial
From the course: Mastering Nest.js: Build Scalable Applications with Mastery in Nest.js Framework
Implementing global pipes
Until now, we have seen various ways of applying pipes that is on the controller level and the parameter level. There is another way and a much better alternative to apply the pipes and that is applying the pipe at a global level. Global pipes keep a watch on the incoming data across the entire application. Rather than applying pipes individually to each route or parameter, global pipes provide a centralized way to handle common tasks like validation, sanitization, or transformation. Let's see how to apply a global pipe. So here in this example, we have applied the validation pipe and a custom phone auth pipe. Now let's say that we want to keep the custom pipe for the post route handler only and want the validation pipe on the entire application. In that case, inside the main TS file, which is the entry point of any nest application, I'll give the app dot use global pipes method. The useGlobalPipes is a built-in method provided by NestJS, whose purpose is to set up global pipes that…
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 pipes1m 59s
-
(Locked)
Built-in pipes (ParseIntPipe)2m 40s
-
(Locked)
Built-in pipes (ParseFloatPipe)1m 7s
-
(Locked)
Built-in pipes (ParseBooleanPipe)2m 25s
-
(Locked)
Built-in pipes (ParseArrayPipe)2m 59s
-
(Locked)
Built-in pipes (ParseUUIDPipe)4m 12s
-
(Locked)
Built-in pipes (ValidationPipe)5m 52s
-
(Locked)
Validating empty fields3m 34s
-
(Locked)
Validating field length3m 4s
-
(Locked)
Custom validation messages3m 2s
-
(Locked)
Validating field using @IsEnum() validator4m 7s
-
(Locked)
Validating dates in Nest.js2m 31s
-
(Locked)
Validating optional fields2m 33s
-
(Locked)
Validating regex pattern3m 11s
-
(Locked)
Creating a custom pipe6m 39s
-
(Locked)
Understanding ArgumentMetadata (metadata.type)3m 40s
-
(Locked)
Assignment: Custom pipe (handling different "type" arguments)3m 56s
-
(Locked)
Understanding ArgumentMetadata (metadata.metatype)5m
-
(Locked)
Understanding ArgumentMetadata (metadata.data)3m 37s
-
(Locked)
Implementing global pipes2m 30s
-
(Locked)
-
-
-
-
-
-
-
-
-