Skip to content
Snippets Groups Projects
main.ts 998 B
Newer Older
  • Learn to ignore specific revisions
  • import { NestFactory } from '@nestjs/core';
    import { AppModule } from './app.module';
    import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
    import { ValidationPipe } from '@nestjs/common';
    
    import * as favicon from 'serve-favicon';
    import * as path from 'path';
    
    import { AppLogger } from './app-logger';
    
    async function bootstrap() {
    
      const app = await NestFactory.create(AppModule, {
    
        logger: new AppLogger(),
    
    
      app.enableCors({ credentials: true, origin: true });
    
      app.use(favicon(path.join(__dirname, '../favicon.ico')));
    
    
      const options = new DocumentBuilder()
        .setBasePath('')
    
        .setTitle('Email service API')
        .setDescription('Service providing the method to send emails.')
    
        .setVersion(process.env.npm_package_version)
    
        .build();
      const document = SwaggerModule.createDocument(app, options);
    
      SwaggerModule.setup('api-doc', app, document);
    
      app.useGlobalPipes(new ValidationPipe());
    
      await app.listen(3000);
    }
    bootstrap();