2026-01-15 21:52:40 +08:00
|
|
|
|
import 'dotenv/config';
|
2026-01-09 23:18:52 +08:00
|
|
|
|
import { NestFactory } from '@nestjs/core';
|
|
|
|
|
|
import { AppModule } from './app.module';
|
2026-01-12 12:28:37 +08:00
|
|
|
|
import { CustomLogger } from './common/logger/logger.service';
|
2026-01-09 23:18:52 +08:00
|
|
|
|
|
|
|
|
|
|
async function bootstrap() {
|
2026-01-13 19:46:41 +08:00
|
|
|
|
const app = await NestFactory.create(AppModule, {
|
|
|
|
|
|
bodyParser: true,
|
|
|
|
|
|
});
|
2026-01-14 22:26:32 +08:00
|
|
|
|
|
2026-01-12 12:28:37 +08:00
|
|
|
|
// 使用自定义日志服务
|
|
|
|
|
|
const logger = await app.resolve(CustomLogger);
|
|
|
|
|
|
app.useLogger(logger);
|
2026-01-14 22:26:32 +08:00
|
|
|
|
|
2026-01-13 19:46:41 +08:00
|
|
|
|
// 增加请求体大小限制(默认 100kb,增加到 50mb)
|
2026-01-14 22:26:32 +08:00
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
|
|
|
|
const express = require('express') as typeof import('express');
|
2026-01-13 19:46:41 +08:00
|
|
|
|
app.use(express.json({ limit: '50mb' }));
|
|
|
|
|
|
app.use(express.urlencoded({ limit: '50mb', extended: true }));
|
2026-01-14 22:26:32 +08:00
|
|
|
|
|
2026-01-13 19:46:41 +08:00
|
|
|
|
// 启用 CORS
|
|
|
|
|
|
app.enableCors();
|
2026-01-14 22:26:32 +08:00
|
|
|
|
|
2026-01-09 23:18:52 +08:00
|
|
|
|
await app.listen(process.env.PORT ?? 3000);
|
|
|
|
|
|
}
|
2026-01-14 22:26:32 +08:00
|
|
|
|
void bootstrap();
|