// GET /api/pam/audit — current user's recent privilege audit entries

import { auth } from "@/auth";
import { listAudit } from "@/lib/pam";

export const dynamic = "force-dynamic";

export async function GET() {
  const session = await auth();
  const user = session?.user as { id?: string } | undefined;
  if (!user?.id) return Response.json({ error: "unauthorized" }, { status: 401 });
  const rows = await listAudit(user.id, 100);
  return Response.json({ audit: rows });
}
