sysmgr-nest/src/main.ts
liuyun 0a0f999589 feat: log startup success and swagger address
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-10 21:47:12 +08:00

32 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'dotenv/config';
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import { Logger } from 'nestjs-pino';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AppModule } from './app.module.js';
async function bootstrap(): Promise<void> {
const app = await NestFactory.create(AppModule, { bufferLogs: true });
app.setGlobalPrefix('api/v1');
app.enableCors();
app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));
app.useLogger(app.get(Logger));
const swaggerConfig = new DocumentBuilder()
.setTitle('系统管理 API')
.setDescription('投云科技系统管理 API 文档')
.setVersion('1.0')
.addBearerAuth()
.build();
SwaggerModule.setup(
'docs',
app,
SwaggerModule.createDocument(app, swaggerConfig),
);
const port = Number(process.env.PORT ?? 3000);
await app.listen(port);
app.get(Logger).log(`服务启动成功,端口 ${port},Swagger 文档: http://localhost:${port}/docs`);
}
await bootstrap();