Skip to content
Snippets Groups Projects
main.ts 879 B
Newer Older
import { ValidationPipe } from '@nestjs/common';
Hugo SUBTIL's avatar
Hugo SUBTIL committed
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
Hugo SUBTIL's avatar
Hugo SUBTIL committed
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule, {
    logger:
      process.env.NODE_ENV === 'production' ? ['error', 'warn', 'log'] : ['log', 'debug', 'error', 'verbose', 'warn'],
  });
  app.useGlobalPipes(new ValidationPipe());
  const options = new DocumentBuilder()
    .setTitle(`Res'in`)
    .setDescription(`Res'in API documentation`)
    .setVersion('1.0')
    .addBearerAuth({ type: 'http', scheme: 'bearer', bearerFormat: 'JWT' }, 'JWT')
    .build();
  app.setGlobalPrefix('api');
  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('api/doc', app, document);
Hugo SUBTIL's avatar
Hugo SUBTIL committed
  await app.listen(3000);
}
bootstrap();