0
0
NestJSframework~10 mins

Module re-exporting in NestJS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to export the imported module in NestJS.

NestJS
import { Module } from '@nestjs/common';
import { UsersModule } from './users.module';

@Module({
  imports: [UsersModule],
  exports: [[1]],
})
export class SharedModule {}
Drag options to blanks, or click blank then click option'
AUsersModule
BSharedModule
CAppModule
DCommonModule
Attempts:
3 left
💡 Hint
Common Mistakes
Exporting the current module instead of the imported one.
Forgetting to export the module after importing.
2fill in blank
medium

Complete the code to re-export multiple modules in NestJS.

NestJS
import { Module } from '@nestjs/common';
import { UsersModule } from './users.module';
import { AuthModule } from './auth.module';

@Module({
  imports: [UsersModule, AuthModule],
  exports: [1],
})
export class SharedModule {}
Drag options to blanks, or click blank then click option'
AUsersModule
B[UsersModule, AuthModule]
CAuthModule
D[]
Attempts:
3 left
💡 Hint
Common Mistakes
Exporting only one module when multiple are imported.
Not using an array for multiple exports.
3fill in blank
hard

Fix the error in the code to properly re-export the imported module.

NestJS
import { Module } from '@nestjs/common';
import { ProductsModule } from './products.module';

@Module({
  imports: [ProductsModule],
  exports: [1],
})
export class InventoryModule {}
Drag options to blanks, or click blank then click option'
AProductsModule
BInventoryModule
C[]
D[ProductsModule]
Attempts:
3 left
💡 Hint
Common Mistakes
Using a single module without array brackets in exports.
Confusing imports and exports syntax.
4fill in blank
hard

Fill both blanks to create a module that imports and re-exports two modules.

NestJS
import { Module } from '@nestjs/common';
import { OrdersModule } from './orders.module';
import { PaymentsModule } from './payments.module';

@Module({
  imports: [[1], [2]],
  exports: [OrdersModule, PaymentsModule],
})
export class TransactionsModule {}
Drag options to blanks, or click blank then click option'
AOrdersModule
BPaymentsModule
CUsersModule
DAuthModule
Attempts:
3 left
💡 Hint
Common Mistakes
Importing modules not listed in exports.
Swapping module names.
5fill in blank
hard

Fill all three blanks to create a module that imports, re-exports, and uses a service from another module.

NestJS
import { Module } from '@nestjs/common';
import { NotificationsModule } from './notifications.module';
import { EmailService } from './email.service';

@Module({
  imports: [[1]],
  exports: [[2]],
  providers: [[3]],
})
export class MessagingModule {}
Drag options to blanks, or click blank then click option'
ANotificationsModule
CEmailService
DAuthService
Attempts:
3 left
💡 Hint
Common Mistakes
Putting services in imports or exports instead of providers.
Not re-exporting the imported module.