feat(ov): ov schema, entry skeleton and compose profile

P2 Task 2 ov 数据层:
- compose ov profile:mysql-ov(mysql:8.4,127.0.0.1:3309,库级
  utf8mb4_0900_bin)+ redis-ov(6381),cn 侧默认 up 不受影响
  (3307/3308 已被其它本机项目占用,端口决策 3309)
- @photo/db-ov:9 表 schema(albums_ov/photos_ov 副本、sync_inbox/
  sync_state 同步账本(水位行同表标志位)、like_batches/album_stats/
  visit_sessions/visit_requests 互动域、outbox_stat_events 回传队列);
  迁移 20260918060102_init_ov 走固化校对手决流程,information_schema
  复核全部业务表/列 utf8mb4_0900_bin(_prisma_migrations 同 cn 先例
  保持 unicode_ci)
- generator 独立 output(包内 generated/):pnpm 将两包 @prisma/client
  提升为同一 store 实例,默认 .prisma/client 输出会被双 schema 互相
  覆盖,ov 客户端独立产出经 src/index.ts 转出口
- ov 入口骨架:main-ov.ts(PORT_OV 默认 8081)+ app-ov.module.ts
  (仅管线骨架 + /v1/health,feature modules 后续任务装配);logger
  装配选项抽取至 shared/logger-options.ts 供 cn/ov 双入口共用(行为
  不变,P1 套件守护)
- test/reset-ov.ts:ov 库 truncate-if-exists 隔离工具(无 MinIO 清理)
- 根脚本:db:generate 双库齐跑,新增 db-ov:migrate/db-ov:generate/dev:ov

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-18 14:11:05 +08:00
parent a4b95abd4c
commit 3d6e9ce175
19 changed files with 578 additions and 30 deletions
+33
View File
@@ -0,0 +1,33 @@
// services/api/src/shared/logger-options.ts —— LoggerModule 装配选项单一来源
// (P2 Task 2 抽取:此前内联在 app-cn.module.ts,ov 入口需要完全相同的
// request-id 解析与凭据打码配置,复制一份即两处漂移点,故收敛于此;cn 模块
// 改为消费本函数,行为不变,由 P1 e2e 套件守护)。
import type { IncomingMessage, ServerResponse } from 'node:http';
import { resolveLogLevel } from './log-level';
import { resolveRequestId } from '../request-id.middleware';
import type { ServerRequestWithId } from './request-with-id';
export function createLoggerOptions() {
return {
pinoHttp: {
// 与 RequestIdMiddleware 共用同一解析函数:优先透传 x-request-id,
// 其次复用已生成的 req.id,否则生成 UUID;并回写响应头。
genReqId: (req: IncomingMessage, res: ServerResponse) =>
resolveRequestId(req as ServerRequestWithId, res),
redact: {
// 授权头 + Cookie(会话凭据,Task 7 遗留项③):请求/响应两侧都打码,
// 防止日志聚合层留存可重放的凭据。
paths: [
'req.headers.authorization',
'req.headers.cookie',
'res.headers.authorization',
'res.headers.set-cookie',
],
censor: '[REDACTED]',
},
// Task 7 遗留项⑤:非法 LOG_LEVEL 在模块装配期(即启动期)快速失败,
// 而不是让 pino 首次写日志时才炸或静默吞掉输出。
level: resolveLogLevel(process.env.LOG_LEVEL),
},
};
}