Recall & Review
beginner
What is a pipe in NestJS?
A pipe in NestJS is a class that transforms or validates data before it reaches the route handler. It helps ensure data is correct and formatted properly.Click to reveal answer
beginner
How do you bind a pipe to a single parameter in NestJS?
You bind a pipe to a parameter by adding it inside the decorator, like @Param('id', ParseIntPipe). This means only that parameter will be processed by the pipe.
Click to reveal answer
intermediate
What happens when you bind a pipe at the method level in NestJS?
Binding a pipe at the method level applies it to all parameters of that method. The pipe runs before the method executes, transforming or validating all inputs.
Click to reveal answer
intermediate
How do you apply a pipe to all routes in a controller?
You add the pipe in the @UsePipes() decorator on the controller class. This makes the pipe run for every route handler inside that controller.
Click to reveal answer
intermediate
What is the effect of binding a pipe globally in NestJS?
Binding a pipe globally means it runs on every request in the app. You do this by adding the pipe in the main.ts file with app.useGlobalPipes().
Click to reveal answer
Where do you bind a pipe to affect only one parameter in NestJS?
✗ Incorrect
Binding a pipe inside the parameter decorator applies it only to that parameter.
What decorator do you use to apply a pipe to all routes in a controller?
✗ Incorrect
Use @UsePipes() on the controller class to apply pipes to all routes inside.
How do you apply a pipe globally in a NestJS app?
✗ Incorrect
Global pipes are set in main.ts using app.useGlobalPipes().
What is the effect of binding a pipe at the method level?
✗ Incorrect
Binding a pipe at the method level applies it to all parameters of that method.
Which of these is NOT a valid way to bind a pipe in NestJS?
✗ Incorrect
Pipes are not bound inside service constructors; they are bound on parameters, methods, controllers, or globally.
Explain how to bind a pipe at different levels in NestJS and what each level affects.
Think about where you place the pipe: on a parameter, method, controller, or globally in main.ts.
You got /4 concepts.
Describe the benefits of using pipes in NestJS and why you might choose different binding levels.
Consider how often you want the pipe to run and on which data.
You got /5 concepts.