rwadurian/backend/services/mining-admin-service/src/main.ts

37 lines
1.2 KiB
TypeScript

import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { SwaggerModule, DocumentBuilder } 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, forbidNonWhitelisted: true }));
app.enableCors({ origin: process.env.CORS_ORIGIN || '*', credentials: true });
app.setGlobalPrefix('api/v2');
const config = new DocumentBuilder()
.setTitle('Mining Admin Service API')
.setDescription('挖矿管理后台 API 文档')
.setVersion('2.0')
.addBearerAuth()
.addTag('Auth', '认证')
.addTag('Config', '配置管理')
.addTag('Dashboard', '仪表盘')
.addTag('Users', '用户管理')
.addTag('Reports', '报表')
.addTag('Audit', '审计日志')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api/docs', app, document);
const port = process.env.PORT || 3023;
await app.listen(port);
console.log(`Mining Admin Service is running on port ${port}`);
console.log(`Swagger docs: http://localhost:${port}/api/docs`);
}
bootstrap();