0
0
NestJSframework~10 mins

Controller decorator 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 basic controller with the correct decorator.

NestJS
import { [1] } from '@nestjs/common';

@[1]('cats')
export class CatsController {}
Drag options to blanks, or click blank then click option'
AInjectable
BService
CModule
DController
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Injectable instead of @Controller
Forgetting to import the decorator
Using @Module or @Service which are not for controllers
2fill in blank
medium

Complete the code to create a controller with the route prefix 'dogs'.

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

@Controller('[1]')
export class DogsController {}
Drag options to blanks, or click blank then click option'
Adogs
Bcats
Cbirds
Dfish
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different route prefix than the controller name
Leaving the prefix empty when a specific route is needed
3fill in blank
hard

Fix the error in the controller decorator import statement.

NestJS
import { [1] } from '@nestjs/common';

@Controller('users')
export class UsersController {}
Drag options to blanks, or click blank then click option'
AController
Bcontroller
CControllers
DControl
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'controller' instead of 'Controller'
Misspelling the decorator name
4fill in blank
hard

Fill both blanks to create a controller with route prefix 'products' and export it.

NestJS
[1] { Controller } from '@nestjs/common';

@[2]('products')
export class ProductsController {}
Drag options to blanks, or click blank then click option'
Aimport
Bexport
CInjectable
DController
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'export' instead of 'import' for bringing in decorators
Using 'Injectable' instead of 'Controller' as decorator
5fill in blank
hard

Fill all three blanks to define and export a controller with route prefix 'orders'.

NestJS
[1] { [2] } from '@nestjs/common';

@[3]('orders')
export class OrdersController {}
Drag options to blanks, or click blank then click option'
Aexport
Bimport
CController
DInjectable
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'export' instead of 'import' for the first blank
Using 'Injectable' instead of 'Controller' for the decorator