import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));

  const config = new DocumentBuilder()
    .setTitle('Genex Gas Relayer')
    .setDescription('Meta-Transaction relay — users sign EIP-712, relayer pays gas')
    .setVersion('1.0')
    .addTag('relay', 'Meta-transaction relay')
    .addTag('accounting', 'Gas subsidy accounting')
    .addTag('health', 'Health checks')
    .build();

  SwaggerModule.setup('docs', app, SwaggerModule.createDocument(app, config));

  const port = process.env.PORT || 3022;
  await app.listen(port);
  console.log(`Gas Relayer running on :${port} | Swagger: /docs`);
}

bootstrap();
