import { Logger } from '@nestjs/common' import { ConfigService } from '@nestjs/config' import { NestFactory } from '@nestjs/core' import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger' import { AppModule } from './core/app.module' async function bootstrap() { const app = await NestFactory.create(AppModule) const logger = new Logger() const config = app.get(ConfigService) app.enableCors({ origin: config.getOrThrow('HTTP_CORS').split(','), credentials: true }) const swaggerConfig = new DocumentBuilder() .setTitle('Teacinema API') .setDescription('API Gateway for Teacinema microservices') .setVersion('1.0.0') .addBearerAuth() .build() const swaggerDocument = SwaggerModule.createDocument(app, swaggerConfig) SwaggerModule.setup('docs', app, swaggerDocument, { yamlDocumentUrl: '/docs/openapi.yaml' }) const port = config.getOrThrow('HTTP_PORT') const host = config.getOrThrow('HTTP_HOST') await app.listen(port) logger.log(`Gateway started: ${host}`) logger.log(`Healthcheck: ${host}health`) logger.log(`Swagger: ${host}docs`) } bootstrap()