| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import { NestFactory, PartialGraphHost } from '@nestjs/core'
- import { AppModule } from './app.module'
- import { Logger, ValidationPipe } from '@nestjs/common'
- import { ConfigService } from '@nestjs/config'
- import { configureSwaggerDocs } from './helpers/configure-swagger-docs.helper'
- import * as fs from 'fs'
- async function bootstrap() {
- const app = await NestFactory.create(AppModule, {
- snapshot: true,
- abortOnError: false
- })
- const configService = app.get<ConfigService>(ConfigService)
- app.setGlobalPrefix('api')
- app.useGlobalPipes(
- new ValidationPipe({
- whitelist: false,
- transform: true,
- forbidNonWhitelisted: false,
- transformOptions: {
- enableImplicitConversion: true
- }
- })
- )
- configureSwaggerDocs(app, configService)
- app.enableCors({
- origin: true,
- methods: 'GET,POST,PUT,PATCH,DELETE',
- credentials: true
- })
- const port = configService.get<number>('NODE_API_PORT') || 3000
- await app.listen(port)
- Logger.log(`Url for OpenApi: ${await app.getUrl()}/docs`, 'Swagger')
- }
- bootstrap().catch((err) => {
- fs.writeFileSync('graph.json', PartialGraphHost.toString() ?? '')
- process.exit(1)
- })
|