What is the role of the next() function in NestJS middleware?
next()
To send a response back to the client.
To pass control to the next middleware in the stack or the route handler.
To terminate the request-response cycle.
To log information about the request.
What is the purpose of the @Get() decorator in NestJS?
@Get()
Handles PUT requests
Handles GET requests
Handles POST requests
Handles DELETE requests
What are the building blocks of a NestJS application called?
Modules
Components
Controllers
Services
What is the role of Providers in NestJS?
To define the application's entry point.
To handle data persistence.
To provide dependencies that can be injected into other components like controllers or services.
To render UI elements.
What is a key advantage of using NestJS over plain Express.js for building Node.js applications?
NestJS enforces a strict project structure and uses TypeScript for better code organization
NestJS is more lightweight and has fewer dependencies
NestJS is faster for handling HTTP requests
NestJS directly interacts with the database, eliminating the need for ORMs
How would you define a route parameter named 'id' in a NestJS route path?
/users/{id}
/users/<id>
/users?id=value
/users/:id
How are controllers related to modules in NestJS?
Modules are defined within controllers.
Controllers and modules are unrelated concepts in NestJS.
Controllers are defined within modules, and their scope is limited to that module.
Controllers exist independently of modules.
What decorator is used for handling HTTP requests meant for updating resources?
@Patch()
@Put()
@Post()
@Delete()
What is the purpose of the return statement in a NestJS controller method?
return
To define the route path
To specify middleware for the route
To send the response to the client
To handle errors within the route
Which decorator is used to mark a class as a provider in NestJS?
@Module()
@Injectable()
@Controller()
@Service()