import { sql } from "@/db"; import { fmtDateTime } from "@/lib/utils"; export default async function Audit({ searchParams }: { searchParams: Promise<{ page?: string }> }) { const page = Math.max(1, Number((await searchParams).page ?? 1)); const rows = await sql`SELECT id, actor, action, entity_type AS "entityType", entity_id AS "entityId", details, ip, created_at AS "createdAt" FROM audit_log ORDER BY id DESC LIMIT 100 OFFSET ${(page - 1) * 100}`; return

Audit log

Append-only (database trigger forbids UPDATE/DELETE). Every editorial change, publication, merge, login and security event.

{rows.map((r) => )}
WhenActorActionEntityDetailsIP
{fmtDateTime(r.createdAt)}{r.actor}{r.action}{r.entityType ? `${r.entityType}:${String(r.entityId).slice(0, 8)}` : ""}{JSON.stringify(r.details)}{r.ip}
{page > 1 && Newer}{rows.length === 100 && Older}
; }