NestJS · Junior · Question 4 of 75

What does main.ts usually contain in a Nest app?

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  await app.listen(process.env.PORT ?? 3000);
}
bootstrap();

Explanation

Global settings also go here: app.setGlobalPrefix('api'), app.useGlobalPipes(...), app.enableCors(), Swagger setup.

Further reading

Problem with a question

NestJS · Junior · question 4

Test yourself

Take the NestJS · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz