Таблица audit_log, recordAudit на мутациях, GET /api/v1/audit и dual-write source_app=fw. Co-authored-by: Cursor <[email protected]>
20 lines
649 B
TypeScript
20 lines
649 B
TypeScript
import type { FastifyPluginAsync } from 'fastify'
|
|
import { listAudit } from '@evofw/db'
|
|
import { auditListQuerySchema } from '@evofw/shared'
|
|
import { AppError } from '../plugins/error-handler.js'
|
|
|
|
export const auditRoutes: FastifyPluginAsync = async (app) => {
|
|
app.get('/audit', async (req) => {
|
|
const parsed = auditListQuerySchema.safeParse(req.query)
|
|
if (!parsed.success) {
|
|
throw new AppError('VALIDATION_ERROR', 'Некорректные параметры запроса', 400)
|
|
}
|
|
const q = parsed.data
|
|
return listAudit(app.db, {
|
|
action: q.action,
|
|
severity: q.severity,
|
|
limit: q.limit,
|
|
})
|
|
})
|
|
}
|