Recall & Review
beginner
What is a global module in NestJS?
A global module is a module that is automatically available across the entire application without needing to import it in other modules.Click to reveal answer
beginner
How do you make a module global in NestJS?
You add the @Global() decorator above the module class and then export the providers you want to share.Click to reveal answer
intermediate
Why use global modules in NestJS?
Global modules help avoid repetitive imports of common services or providers in many modules, making code cleaner and easier to maintain.
Click to reveal answer
intermediate
Can you import a global module multiple times in NestJS?No, once a module is marked global, you do not need to import it in other modules. Importing it again has no effect.Click to reveal answer
beginner
Show a simple example of a global module in NestJS.
```typescript
import { Module, Global } from '@nestjs/common';
@Global()
@Module({
providers: [CommonService],
exports: [CommonService],
})
export class CommonModule {}
```Click to reveal answer
What decorator makes a module global in NestJS?
✗ Incorrect
The @Global() decorator marks a module as global so it can be used without importing it everywhere.
If a module is global, do you need to import it in every other module?
✗ Incorrect
Global modules are automatically available in all modules without importing.
What must you do to share a service from a global module?
✗ Incorrect
You must export the service in the module's exports array to share it.
Which of these is NOT a benefit of global modules?
✗ Incorrect
Global modules do not affect module reloading behavior.
Where do you place the @Global() decorator?
✗ Incorrect
The @Global() decorator is placed above the module class declaration.
Explain how to create and use a global module in NestJS.
Think about how to share services app-wide without importing everywhere.
You got /4 concepts.
What are the advantages and possible downsides of using global modules in NestJS?
Consider both code simplicity and clarity.
You got /2 concepts.