/* eslint-disable import/no-duplicates */ /* eslint-disable unicorn/prefer-top-level-await */ import { AppModule } from './app.module'; import { env } from './config/env'; import { fastifyCookie } from '@fastify/cookie'; import type { INestApplication } from '@nestjs/common'; import { ValidationPipe } from '@nestjs/common'; import { NestFactory } from '@nestjs/core'; import type { NestFastifyApplication } from '@nestjs/platform-fastify'; import { FastifyAdapter } from '@nestjs/platform-fastify'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; function setupOpenApi(app: INestApplication) { const config = new DocumentBuilder() .setTitle('Evo.Auth') .setVersion('1.0') // .addTag('api') .build(); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('swagger', app, document, { useGlobalPrefix: true }); } async function bootstrap() { const app = await NestFactory.create( AppModule, new FastifyAdapter({ logger: true, }) ); await app.register(fastifyCookie, { secret: env.API_SECRET, }); app.useGlobalPipes(new ValidationPipe({ stopAtFirstError: true })); setupOpenApi(app); await app.listen(env.API_PORT, '0.0.0.0'); } bootstrap();