import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  // 设置全局前缀
  app.setGlobalPrefix('api/v1', { exclude: ['health'] });

  // 启用CORS
  app.enableCors({
    origin: process.env.CORS_ORIGIN || '*',
    credentials: true,
  });

  const port = process.env.PORT || 3005;
  await app.listen(port);

  console.log(`
╔══════════════════════════════════════════════════════════════╗
║                                                              ║
║   🧬 iConsulting Evolution Service                          ║
║                                                              ║
║   Server running at: http://localhost:${port}                  ║
║   API prefix: /api/v1                                        ║
║                                                              ║
║   Endpoints:                                                 ║
║   - POST   /api/v1/admin/login            Admin login        ║
║   - GET    /api/v1/admin/me               Current admin      ║
║   - POST   /api/v1/admin/admins           Create admin       ║
║   - GET    /api/v1/admin/admins           List admins        ║
║   - POST   /api/v1/evolution/run          Run evolution      ║
║   - GET    /api/v1/evolution/statistics   Evolution stats    ║
║   - GET    /api/v1/evolution/health       System health      ║
║                                                              ║
╚══════════════════════════════════════════════════════════════╝
  `);
}

bootstrap();
