Recall & Review
beginner
What is the purpose of the @Module decorator in NestJS?
The @Module decorator defines a module in NestJS. It organizes related components like controllers, providers, and imports into a single unit, helping structure the app clearly.
Click to reveal answer
beginner
Name the main metadata properties used inside the @Module decorator.
The main properties are: <br>• imports: other modules to include<br>• controllers: classes handling incoming requests<br>• providers: services or classes that provide functionality<br>• exports: providers made available to other modules
Click to reveal answer
intermediate
How does the 'imports' property in @Module metadata work?
The 'imports' property lists other modules whose exported providers are needed in this module. It allows sharing functionality between modules.
Click to reveal answer
intermediate
What happens if you forget to add a provider to the 'providers' array in a module?
NestJS will not recognize the provider as injectable in that module, causing errors when trying to use it in controllers or other providers.
Click to reveal answer
intermediate
Explain the role of the 'exports' property in the @Module decorator.
The 'exports' property makes selected providers available to other modules that import this module. It helps share services across different parts of the app.Click to reveal answer
Which property in the @Module decorator lists the controllers of the module?
✗ Incorrect
The 'controllers' property holds the classes that handle incoming requests in the module.
What does the 'providers' array in a module contain?
✗ Incorrect
The 'providers' array contains services or classes that provide business logic or functionality.
If you want to use a service from another module, which property should you use in your module?
✗ Incorrect
You add the other module to the 'imports' array to use its exported providers.
What is the effect of adding a provider to the 'exports' array?
✗ Incorrect
Adding a provider to 'exports' shares it with other modules that import this module.
Which decorator is used to define a module in NestJS?
✗ Incorrect
The '@Module' decorator defines a module and its metadata.
Describe how the @Module decorator organizes an application in NestJS.
Think about how a folder groups related files.
You got /3 concepts.
Explain the roles of 'imports' and 'exports' in the @Module metadata.
Consider how you borrow and lend things between friends.
You got /3 concepts.