0
0
NestJSframework~10 mins

Module decorator and metadata 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 define a NestJS module with the @Module decorator.

NestJS
import { Module } from '@nestjs/common';

@Module({
  [1]: [],
})
export class AppModule {}
Drag options to blanks, or click blank then click option'
Aimports
Bcomponents
Cservices
Dcontrollers
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'components' or 'services' which are not valid properties in @Module.
Confusing 'controllers' with 'imports'.
2fill in blank
medium

Complete the code to add a controller to the module metadata.

NestJS
@Module({
  controllers: [[1]],
})
export class UserModule {}
Drag options to blanks, or click blank then click option'
AUserEntity
BUserService
CAppModule
DUserController
Attempts:
3 left
💡 Hint
Common Mistakes
Putting services or entities inside the controllers array.
Confusing controller with service names.
3fill in blank
hard

Fix the error in the module metadata by completing the providers array correctly.

NestJS
@Module({
  providers: [[1]],
})
export class AuthModule {}
Drag options to blanks, or click blank then click option'
AAuthModule
BAuthController
CAuthService
DAuthEntity
Attempts:
3 left
💡 Hint
Common Mistakes
Adding controllers or modules to providers array.
Confusing entities with providers.
4fill in blank
hard

Fill both blanks to complete the module metadata with imports and exports.

NestJS
@Module({
  [1]: [CommonModule],
  [2]: [CommonModule],
})
export class SharedModule {}
Drag options to blanks, or click blank then click option'
Aimports
Bproviders
Cexports
Dcontrollers
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up exports with providers or controllers.
Using providers instead of exports to share modules.
5fill in blank
hard

Fill all three blanks to complete a module with imports, controllers, and providers.

NestJS
@Module({
  [1]: [DatabaseModule],
  [2]: [AppController],
  [3]: [AppService],
})
export class AppModule {}
Drag options to blanks, or click blank then click option'
Aimports
Bcontrollers
Cproviders
Dexports
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping controllers and providers.
Putting modules in providers or controllers.