Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing Module with Controller or Service.
✗ Incorrect
The Module decorator is essential in NestJS to define application modules.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated route names like 'main' or 'root'.
✗ Incorrect
The controller path is usually named app for the main route.
3fill in blank
hardFix the error in the NestJS service provider declaration.
NestJS
@Injectable() export class [1]Service {}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using controller names or incomplete names without 'Service' suffix.
✗ Incorrect
Service classes in NestJS are usually named with the suffix Service, like AppService.
4fill in blank
hardFill both blanks to define a NestJS module with a controller and a provider.
NestJS
@Module({
controllers: [[1]],
providers: [[2]],
})
export class AppModule {} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing controller and service names or using unrelated names.
✗ Incorrect
The module should list the AppController in controllers and AppService in providers.
5fill in blank
hardFill all three blanks to create a simple NestJS app bootstrap function.
NestJS
async function bootstrap() {
const app = await NestFactory.[1](AppModule);
await app.[2](3000);
console.log('Application is running on port', [3]);
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong method names like 'start' or missing the port number.
✗ Incorrect
The app is created with create, listens on port 3000, and logs the port number.