import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { Logger } from '@nestjs/common';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { ResponseInterceptor } from './common/interceptors/response.interceptor';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.setGlobalPrefix('api');
  app.useGlobalInterceptors(new ResponseInterceptor());
  const config = new DocumentBuilder()
    .setTitle('交换机API平台')
    .setDescription('自动化交换机配置和流量监控接口')
    .setVersion('1.0')
    .build();
  const document = () => SwaggerModule.createDocument(app, config);
  SwaggerModule.setup('', app, document);
  await app.listen(8000);
}
bootstrap().then(() => {
  Logger.log(`API服务已启动：http://localhost:8000`);
  Logger.log(`API文档： http://localhost:8000/api`);
});
