0
0
NestJSframework~10 mins

Why production readiness matters in NestJS - Test Your Understanding

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

Complete the code to import the core module in a NestJS application.

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

Complete the code to create a basic controller in NestJS.

NestJS
@Controller('[1]')
export class AppController {}
Drag options to blanks, or click blank then click option'
Acontroller
Bservice
Cmodule
Dapp
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'service' as route prefix
Using 'module' as route prefix
3fill in blank
hard

Fix the error in the provider registration to ensure production readiness.

NestJS
@Module({
  providers: [[1]],
})
export class AppModule {}
Drag options to blanks, or click blank then click option'
AHttpModule
BAppController
CAppService
DConfigModule
Attempts:
3 left
💡 Hint
Common Mistakes
Registering controllers as providers
Registering modules as providers
4fill in blank
hard

Fill both blanks to configure environment variables and enable validation for production readiness.

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

@Module({
  imports: [[2].forRoot({ isGlobal: true })],
})
export class AppModule {}
Drag options to blanks, or click blank then click option'
AConfigModule
BValidationPipe
CConfigService
DHttpModule
Attempts:
3 left
💡 Hint
Common Mistakes
Using ValidationPipe instead of ConfigModule
Importing ConfigService directly
5fill in blank
hard

Fill all three blanks to set up a global validation pipe and enable CORS for production readiness.

NestJS
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.useGlobalPipes(new [1]());
  app.enableCors({ origin: [2] });
  await app.listen([3]);
}
Drag options to blanks, or click blank then click option'
AValidationPipe
B'*'
C3000
DHttpException
Attempts:
3 left
💡 Hint
Common Mistakes
Using HttpException instead of ValidationPipe
Setting CORS origin to an invalid value
Using a wrong port number