NestJS 11 + Fastify 统一错误体与 trace_id,/health 真实探活 DB/Redis,OpenAPI 3.1 契约含 20 个错误码;shared 包提供错误码、权限点、ULID、分页与通用 schema;worker 完成队列进程骨架。
26 lines
816 B
TypeScript
26 lines
816 B
TypeScript
import { ApiProperty } from '@nestjs/swagger';
|
|
|
|
/** OpenAPI 错误响应模型(工程规范 04 统一错误体) */
|
|
export class ErrorResponseDto {
|
|
@ApiProperty({ type: Number, description: '错误码(见 ErrorCode 常量)', example: 42202 })
|
|
code!: number;
|
|
|
|
@ApiProperty({ type: String, description: '可直接展示给用户的提示', example: '内容触发合规拦截' })
|
|
message!: string;
|
|
|
|
@ApiProperty({
|
|
type: Object,
|
|
description: '补充信息(字段错误、命中规则等),结构由错误码决定',
|
|
required: false,
|
|
example: { issues: [{ path: 'name', message: 'Required' }] },
|
|
})
|
|
details?: unknown;
|
|
|
|
@ApiProperty({
|
|
type: String,
|
|
description: '请求追踪 ID,与日志同源',
|
|
example: '01JABCDEF0123456789ABCDEFG',
|
|
})
|
|
trace_id!: string;
|
|
}
|