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 || 3004;
  await app.listen(port);

  console.log(`
╔══════════════════════════════════════════════════════════════╗
║                                                              ║
║   🧠 iConsulting Knowledge Service                          ║
║                                                              ║
║   Server running at: http://localhost:${port}                  ║
║   API prefix: /api/v1                                        ║
║                                                              ║
║   Endpoints:                                                 ║
║   - POST   /api/v1/knowledge/articles      Create article    ║
║   - GET    /api/v1/knowledge/articles      List articles     ║
║   - POST   /api/v1/knowledge/retrieve      RAG retrieval     ║
║   - POST   /api/v1/memory/user             Save memory       ║
║   - POST   /api/v1/memory/experience       Save experience   ║
║   - GET    /api/v1/memory/experience/pending  Pending exp.   ║
║                                                              ║
╚══════════════════════════════════════════════════════════════╝
  `);
}

bootstrap();
