docs: 基本完成初版数据库设计

This commit is contained in:
R524809
2026-10-15 10:09:34 +08:00
parent 63a6993276
commit e6ded00a4c
41 changed files with 2597 additions and 180 deletions
+31
View File
@@ -0,0 +1,31 @@
import { NestFactory } from '@nestjs/core';
import type { NestExpressApplication } from '@nestjs/platform-express';
import { AppModule } from './app.module';
import { configureApplication } from './app.setup';
import { getServerConfig, type ServerConfig } from './config/server-config';
import { AppLogger } from './logging/app-logger';
/** 创建并配置应用,但不监听端口;启动入口和测试均通过此工厂组装服务。 */
export async function createApplication(
config: ServerConfig = getServerConfig(),
logger = new AppLogger(config.logLevel),
): Promise<NestExpressApplication> {
const app = await NestFactory.create<NestExpressApplication>(
AppModule.forRoot(config),
{
// 解析器由 configureApplication 显式安装,确保大小限制和注册顺序一致。
bodyParser: false,
logger,
// 将初始化错误交给调用方处理,不在 Nest 内部直接退出整个进程。
abortOnError: false,
},
);
try {
configureApplication(app, config, logger);
return app;
} catch (error) {
// 配置阶段失败也关闭已经建立的资源,避免测试或重复启动遗留句柄。
await app.close();
throw error;
}
}