MCPcopy Create free account
hub / github.com/Braineanear/EcommerceAPI / bootstrap

Function bootstrap

monolithic/src/main.ts:11–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9import { AppModule } from './app/app.module';
10
11async function bootstrap() {
12 const app = await NestFactory.create(AppModule);
13 const logger = new Logger();
14 const configService = app.get(ConfigService);
15 const env = configService.get<string>('app.env');
16 const schema = {
17 production: configService.get<string>('app.productionURL'),
18 staging: configService.get<string>('app.stagingURL'),
19 development: configService.get<string>('app.developmentURL'),
20 local: configService.get<string>('app.localURL'),
21 };
22 const options = new DocumentBuilder()
23 .setTitle('API')
24 .setVersion('0.0.1')
25 .addBearerAuth()
26 .addServer(schema[env])
27 .build();
28 const document = SwaggerModule.createDocument(app, options);
29
30 SwaggerModule.setup('docs', app, document);
31
32 app.enableCors();
33 app.use(helmet());
34 app.useGlobalPipes(new ValidationPipe());
35
36 await app.listen(configService.get<number>('app.port'));
37
38 logger.log(`==========================================================`);
39 logger.log(`App Environment is ${env}`, 'NestApplication');
40
41 logger.log(`==========================================================`);
42
43 logger.log(`Server running on ${await app.getUrl()}`, 'NestApplication');
44
45 logger.log(`==========================================================`);
46}
47bootstrap();

Callers 1

main.tsFile · 0.85

Calls 2

useMethod · 0.80
createMethod · 0.65

Tested by

no test coverage detected