0
0
NestJSframework~5 mins

Decorator-based architecture in NestJS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a decorator in NestJS?
A decorator in NestJS is a special function that adds metadata or behavior to classes, methods, or properties. It helps organize code by marking parts with extra information NestJS uses to build the app.
Click to reveal answer
beginner
How does the @Controller() decorator work in NestJS?
The @Controller() decorator marks a class as a controller that handles incoming HTTP requests. It tells NestJS to group related routes inside this class.
Click to reveal answer
beginner
What role do method decorators like @Get() or @Post() play in NestJS?
Method decorators like @Get() or @Post() define which HTTP method and route a class method should respond to. They connect URLs to specific functions.
Click to reveal answer
intermediate
Why is decorator-based architecture helpful in NestJS?
It keeps code clean and easy to read by clearly showing what each part does. It also helps NestJS automatically build the app structure and handle requests without extra setup.
Click to reveal answer
intermediate
Can you explain how dependency injection uses decorators in NestJS?
Decorators like @Injectable() mark classes as services that NestJS can create and share. Then, constructor parameters typed with classes let NestJS automatically provide those services where needed.
Click to reveal answer
What does the @Injectable() decorator do in NestJS?
AMarks a class as a service that can be injected
BDefines a route handler
CMarks a class as a controller
DCreates a database connection
Which decorator would you use to handle HTTP GET requests in NestJS?
A@Post()
B@Get()
C@Controller()
D@Injectable()
What is the main purpose of decorators in NestJS architecture?
ATo create database tables
BTo write CSS styles
CTo add metadata and organize code structure
DTo run JavaScript in the browser
How does NestJS know which class is a controller?
ABy the class name
BBy the file extension
CBy the @Injectable() decorator
DBy the @Controller() decorator
Which decorator helps NestJS inject dependencies automatically?
A@Injectable()
B@Post()
C@Controller()
D@Get()
Describe how decorators help organize a NestJS application.
Think about how NestJS uses special marks to know what each part does.
You got /4 concepts.
    Explain the role of @Controller() and @Get() decorators in handling web requests.
    Focus on how NestJS matches URLs to functions.
    You got /4 concepts.