Recall & Review
beginner
What is the main role of a controller in NestJS?
A controller in NestJS handles incoming HTTP requests and returns responses. It acts like a receptionist who listens to requests and directs them to the right place.
Click to reveal answer
beginner
Why do controllers handle incoming requests instead of services?
Controllers focus on receiving and managing requests, while services handle business logic. This separation keeps code organized and easier to maintain.
Click to reveal answer
intermediate
How does a controller know which requests to handle?
Controllers use decorators like @Get(), @Post() to match specific HTTP methods and routes. This is like setting up signs to guide requests to the right handler.
Click to reveal answer
beginner
What happens inside a controller when a request arrives?
The controller receives the request, extracts needed data, calls the service for processing, and sends back the response to the client.
Click to reveal answer
beginner
Why is it important for controllers to handle requests in a web app?
Controllers act as the first contact point for users. They ensure requests are understood and routed correctly, making the app responsive and organized.
Click to reveal answer
In NestJS, what decorator is used to define a controller method that handles GET requests?
✗ Incorrect
The @Get() decorator marks a method to handle HTTP GET requests.
Which part of a NestJS app is responsible for business logic?
✗ Incorrect
Services contain business logic, while controllers handle requests.
What does a controller do after receiving a request?
✗ Incorrect
Controllers call services to process data and then send a response.
Why is separating controllers and services useful?
✗ Incorrect
Separation keeps code clean and easier to manage.
Which decorator defines a class as a controller in NestJS?
✗ Incorrect
The @Controller() decorator marks a class as a controller.
Explain why controllers handle incoming requests in NestJS and how they interact with services.
Think of controllers as the app's receptionist.
You got /5 concepts.
Describe the benefits of separating request handling in controllers from business logic in services.
Consider how teamwork works best when roles are clear.
You got /5 concepts.