feat: add production assurance dashboard flow

This commit is contained in:
thanhnv
2026-07-28 21:49:15 +07:00
parent ee5d1f7af5
commit cce3cbfd42
39 changed files with 1873 additions and 91 deletions
@@ -1,4 +1,4 @@
import { BadRequestException, Controller, Get, Header, Inject, Query, Res } from '@nestjs/common';
import { BadRequestException, Controller, Get, Header, Inject, Param, Query, Res } from '@nestjs/common';
import type { Response } from 'express';
import { ok } from '../common/api-response.js';
import { parseH6ReportQuery, type H6ReportQueryParams } from './h6-report.js';
@@ -34,4 +34,24 @@ export class ReportsController {
response.setHeader('Content-Disposition', `attachment; filename="casan-h6-report-${stamp}.${format}"`);
response.send(body);
}
@Get('run/:traceId')
run(@Param('traceId') traceId: string) {
return ok(this.reports.run(traceId));
}
@Get('run/:traceId/export')
@Header('Cache-Control', 'no-store')
exportRun(
@Param('traceId') traceId: string,
@Query('format') rawFormat: string | undefined,
@Res() response: Response,
) {
const format = rawFormat ?? 'json';
if (format !== 'json' && format !== 'html') throw new BadRequestException('RUN_REPORT_INVALID_FORMAT');
const report = this.reports.run(traceId);
response.type(format === 'html' ? 'text/html; charset=utf-8' : 'application/json; charset=utf-8');
response.setHeader('Content-Disposition', `attachment; filename="casan-run-${traceId}.${format}"`);
response.send(this.reports.serializeRun(report, format));
}
}