feat: 初始化DevOps平台后端
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import { AppModule } from './app.module';
|
||||
import { ApiEnvelopeInterceptor } from './common/http/api-envelope.interceptor';
|
||||
import { AllExceptionsFilter } from './common/http/all-exceptions.filter';
|
||||
import { EnvConfig } from './config/env.schema';
|
||||
|
||||
async function bootstrap(): Promise<void> {
|
||||
const app = await NestFactory.create(AppModule, {
|
||||
bufferLogs: true,
|
||||
rawBody: true,
|
||||
});
|
||||
const config = app.get(ConfigService<EnvConfig, true>);
|
||||
const corsOrigin = config.get('CORS_ORIGIN', { infer: true });
|
||||
|
||||
app.enableCors({
|
||||
origin: corsOrigin ? corsOrigin.split(',').map((origin) => origin.trim()) : true,
|
||||
credentials: true,
|
||||
});
|
||||
app.useGlobalFilters(new AllExceptionsFilter());
|
||||
app.useGlobalInterceptors(new ApiEnvelopeInterceptor());
|
||||
|
||||
const swaggerConfig = new DocumentBuilder()
|
||||
.setTitle('DevOps Platform API')
|
||||
.setDescription('Jenkins, Gitea, notification, BPMN deploy runs, and agent operation APIs.')
|
||||
.setVersion('0.1.0')
|
||||
.build();
|
||||
const document = SwaggerModule.createDocument(app, swaggerConfig);
|
||||
SwaggerModule.setup('docs', app, document);
|
||||
|
||||
await app.listen(config.get('PORT', { infer: true }));
|
||||
}
|
||||
|
||||
void bootstrap();
|
||||
Reference in New Issue
Block a user