0
0
NestJSframework~10 mins

First NestJS application - 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 Controller decorator from NestJS.

NestJS
import { [1] } from '@nestjs/common';
Drag options to blanks, or click blank then click option'
AController
BModule
CInjectable
DNestFactory
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing Module with Controller
Using NestFactory which is for app creation
2fill in blank
medium

Complete the code to create a basic controller class named AppController.

NestJS
export class [1]Controller {}
Drag options to blanks, or click blank then click option'
AMain
BApp
CRoot
DHome
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated names like Home or Root
Forgetting to export the class
3fill in blank
hard

Fix the error in the decorator to define a module with AppController.

NestJS
@Module({
  controllers: [[1]Controller],
})
export class AppModule {}
Drag options to blanks, or click blank then click option'
AMain
BRoot
CApp
DHome
Attempts:
3 left
💡 Hint
Common Mistakes
Using a controller name that was not defined
Forgetting to include the controller in the module
4fill in blank
hard

Fill both blanks to create and start the NestJS application.

NestJS
async function bootstrap() {
  const app = await [1].create([2]Module);
  await app.listen(3000);
}
Drag options to blanks, or click blank then click option'
ANestFactory
BApp
CAppModule
DModule
Attempts:
3 left
💡 Hint
Common Mistakes
Using Module instead of AppModule
Using App instead of NestFactory
5fill in blank
hard

Fill in the blanks to define a simple GET route returning 'Hello World!'.

NestJS
@Controller()
export class AppController {
  @[1]()
  getHello(): string {
    return [2];
  }
}
Drag options to blanks, or click blank then click option'
AGet
B'Hello World!'
C"Hello World!"
DPost
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Post instead of @Get
Returning the string without quotes
Using single quotes inconsistently