feat: 接通后台渲染异常上报与响应契约校验
This commit is contained in:
1 parent
330d67adc1
commit
adcaa12970
22 files changed
+845
-33
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import { AdminBrand } from "../../admin-auth.decorators.js";
|
||||
import { Body, Controller, Post, Req } from "@nestjs/common";
|
||||
import type { FastifyRequest } from "fastify";
|
||||
import { AdminAccessService } from "../../admin-access.service.js";
|
||||
import { CreateClientErrorDto } from "../../client-error.dto.js";
|
||||
import { AdminClientErrorService } from "./admin-client-error.service.js";
|
||||
|
||||
@AdminBrand()
|
||||
@Controller("admin/client-errors")
|
||||
export class AdminClientErrorController {
|
||||
constructor(
|
||||
private readonly access: AdminAccessService,
|
||||
private readonly errors: AdminClientErrorService,
|
||||
) {}
|
||||
|
||||
@Post()
|
||||
async create(
|
||||
@Req() request: FastifyRequest,
|
||||
@Body() body: CreateClientErrorDto,
|
||||
): Promise<{ received: true; duplicate: boolean }> {
|
||||
const identity = await this.access.requireBrand(request);
|
||||
return this.errors.record({
|
||||
subject: identity.subject,
|
||||
brandId: identity.brandId,
|
||||
errorId: body.errorId,
|
||||
message: body.message,
|
||||
route: body.route,
|
||||
componentStack: body.componentStack,
|
||||
requestId:
|
||||
(request as FastifyRequest & { requestId?: string }).requestId ??
|
||||
request.headers["x-request-id"]?.toString() ??
|
||||
null,
|
||||
userAgent: request.headers["user-agent"]?.toString().slice(0, 300) ?? null,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user