Files
photo-live/services/api/src/main-cn.ts
T
2026-09-18 15:21:41 +08:00

28 lines
1.3 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.
// services/api/src/main-cn.ts
// cn-app 部署入口(P1a 仅此一个 API 入口)。构建产物 dist/main-cn.js 由根 dev:api /
// 生产启动命令运行;env 一律来自进程环境(根 dotenv-cli 注入),此处不读文件。
import 'reflect-metadata';
import { NestFactory } from '@nestjs/core';
import { type NestExpressApplication } from '@nestjs/platform-express';
import { Logger } from 'nestjs-pino';
import { AppCnModule } from './app-cn.module';
import { configureApp } from './shared/configure-app';
async function bootstrap(): Promise<void> {
const app = await NestFactory.create<NestExpressApplication>(AppCnModule, {
bufferLogs: true,
// 内部 sync 端点(bootstrap/reconcile)HMAC 验签需要「原始请求体字节」:
// rawBody 让 body-parser 在 JSON 解析前把 Buffer 挂到 req.rawBody
// (InternalSyncGuard 读取)。与 JSON.parse 后的 body 再序列化相比,
// 原始字节不受键序/空白影响,签名两端一致(Task 3 执行注意)。
rawBody: true,
});
app.useLogger(app.get(Logger));
configureApp(app);
const port = Number.parseInt(process.env.PORT ?? '', 10) || 8080;
await app.listen(port);
app.get(Logger).log(`api-cn listening on port ${port}`);
}
void bootstrap();