- Introduce LoggingMiddleware to log incoming requests and their response times - Update AppModule to apply the new logging middleware globally - Increase API request timeout from 10 seconds to 60 seconds - Modify PromptString to include additional project types of interest
27 lines
810 B
TypeScript
27 lines
810 B
TypeScript
import 'dotenv/config';
|
||
import { NestFactory } from '@nestjs/core';
|
||
import { AppModule } from './app.module';
|
||
import { CustomLogger } from './common/logger/logger.service';
|
||
|
||
async function bootstrap() {
|
||
const app = await NestFactory.create(AppModule, {
|
||
bodyParser: true,
|
||
});
|
||
|
||
// 使用自定义日志服务
|
||
const logger = await app.resolve(CustomLogger);
|
||
app.useLogger(logger);
|
||
|
||
// 增加请求体大小限制(默认 100kb,增加到 50mb)
|
||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||
const express = require('express') as typeof import('express');
|
||
app.use(express.json({ limit: '50mb' }));
|
||
app.use(express.urlencoded({ limit: '50mb', extended: true }));
|
||
|
||
// 启用 CORS
|
||
app.enableCors();
|
||
|
||
await app.listen(process.env.PORT ?? 3000);
|
||
}
|
||
void bootstrap();
|