feat(api): 搭建 API 与 Worker 骨架及契约基线

NestJS 11 + Fastify 统一错误体与 trace_id,/health 真实探活 DB/Redis,OpenAPI 3.1 契约含 20 个错误码;shared 包提供错误码、权限点、ULID、分页与通用 schema;worker 完成队列进程骨架。
This commit is contained in:
Stev_Wang committed 2026-11-02 17:20:46 +08:00
1 parent 09dbb27b66
commit 23067edb8f
70 files changed
+2445

No files matched your search

@@ -0,0 +1,25 @@
import { ERROR_MESSAGES, type ErrorCode, httpStatusOf } from '@lingxi/shared';
export interface AppExceptionOptions {
code: ErrorCode;
message?: string;
details?: unknown;
}
/**
* 业务异常:由统一异常过滤器序列化为 { code, message, details, trace_id }。
* 业务代码禁止直接 throw new Error 表达可预期错误。
*/
export class AppException extends Error {
readonly code: ErrorCode;
readonly status: number;
readonly details?: unknown;
constructor(options: AppExceptionOptions) {
super(options.message ?? ERROR_MESSAGES[options.code]);
this.name = 'AppException';
this.code = options.code;
this.status = httpStatusOf(options.code);
this.details = options.details;
}
}