0
0
NestJSframework~10 mins

Root module (AppModule) 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 import the core NestJS module decorator.

NestJS
import { [1] } from '@nestjs/common';
Drag options to blanks, or click blank then click option'
AModule
BController
CInjectable
DService
Attempts:
3 left
💡 Hint
Common Mistakes
Using Controller or Injectable instead of Module
Forgetting to import the decorator
2fill in blank
medium

Complete the code to define the root module class named AppModule.

NestJS
@Module({})
export class [1] {}
Drag options to blanks, or click blank then click option'
AMainModule
BCoreModule
CRootModule
DAppModule
Attempts:
3 left
💡 Hint
Common Mistakes
Using other names like MainModule or RootModule
Not exporting the class
3fill in blank
hard

Fix the error in the module decorator to include an empty imports array.

NestJS
@Module({ imports: [1] })
export class AppModule {}
Drag options to blanks, or click blank then click option'
A{}
Bnull
C[]
Dundefined
Attempts:
3 left
💡 Hint
Common Mistakes
Using null or undefined instead of an empty array
Omitting the imports property
4fill in blank
hard

Fill both blanks to add a controller and a provider to the module metadata.

NestJS
@Module({
  controllers: [[1]],
  providers: [[2]]
})
export class AppModule {}
Drag options to blanks, or click blank then click option'
AAppController
BAppService
CMainController
DMainService
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing controllers and providers
Using undefined names
5fill in blank
hard

Fill all three blanks to import a module, add a controller, and add a provider in AppModule.

NestJS
import { Module } from '@nestjs/common';
import { [1] } from './cats/cats.module';
import { [2] } from './cats/cats.controller';
import { [3] } from './cats/cats.service';

@Module({
  imports: [[1]],
  controllers: [[2]],
  providers: [[3]]
})
export class AppModule {}
Drag options to blanks, or click blank then click option'
ACatsModule
BCatsController
CCatsService
DCatsProvider
Attempts:
3 left
💡 Hint
Common Mistakes
Using CatsProvider which does not exist
Mixing up controller and service names