import { NestFactory } from '@nestjs/core'; import { NestExpressApplication } from '@nestjs/platform-express'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { AppModule } from './app.module'; import { configureApp } from './app.config'; const REQUIRED_ENV_VARS = ['DATABASE_URL', 'JWT_ACCESS_SECRET'] as const; function assertRequiredEnvVars(): void { const missing = REQUIRED_ENV_VARS.filter((name) => !process.env[name]); if (missing.length > 0) { throw new Error( `Missing required environment variable(s): ${missing.join(', ')}`, ); } } async function bootstrap() { assertRequiredEnvVars(); const app = await NestFactory.create(AppModule); app.enableShutdownHooks(); configureApp(app); const swaggerConfig = new DocumentBuilder() .setTitle('ApiCore API') .setDescription('Digitale Imkereiverwaltung – API-Dokumentation') .setVersion('1.0') .addBearerAuth() .build(); const swaggerDocument = SwaggerModule.createDocument(app, swaggerConfig); SwaggerModule.setup('api/v1/docs', app, swaggerDocument); await app.listen(process.env.PORT ?? 3001); } void bootstrap();