Recall & Review
beginner
What is a shared module in NestJS?
A shared module is a module that exports providers, components, or services so other modules can use them without redefining. It helps reuse code across the app.
Click to reveal answer
beginner
How do you make a module shared in NestJS?
You export the providers or components inside the module's @Module decorator using the 'exports' array. Then import this module in other modules to use the shared parts.Click to reveal answer
intermediate
Does importing a shared module multiple times create multiple instances of its providers in NestJS?
No, NestJS automatically shares a single instance of providers across all modules that import it.Click to reveal answer
beginner
What is the difference between 'imports' and 'exports' in a NestJS module?
'imports' bring in other modules to use their exported providers. 'exports' make providers from the current module available to other modules that import it.Click to reveal answer
intermediate
Can a shared module import other modules? What happens then?Yes, a shared module can import other modules. Those imported modules' exported providers become available inside the shared module, but are not automatically exported to modules importing the shared module.Click to reveal answer
What must you do to make a service available to other modules in NestJS?
✗ Incorrect
You export the service in the module's exports array so other modules importing this module can use it.
If you import a shared module in multiple modules, what happens to its providers?
✗ Incorrect
Providers in a shared module are singletons and shared across imports unless explicitly scoped differently.
Which decorator property lists modules that this module depends on?
✗ Incorrect
'imports' lists modules whose exported providers are needed inside this module.
What is the main benefit of using shared modules?
✗ Incorrect
Shared modules help reuse code and services across different parts of the app, reducing duplication.
If a shared module imports another module, do the imported module's exports become available to modules importing the shared module?
✗ Incorrect
The shared module must re-export the imported module's exports to make them available to modules importing the shared module.
Explain how to create and use a shared module in NestJS.
Think about how to share services across modules without rewriting them.
You got /4 concepts.
Describe the difference between 'imports' and 'exports' in a NestJS module and why both are important.
Consider how modules connect and share code.
You got /4 concepts.