// PEP-254: the owner downloads their whole Access Hub journal with hashes (JSONL or CSV) to // check it on their own. Only the signed-in user's own rows. import { exportConnectionJournal } from "@peppa/core"; import { currentUser } from "@/lib/auth"; import { db } from "@/lib/db"; import { getT } from "@/lib/i18n"; export const dynamic = "force-dynamic"; export async function GET(req: Request) { const t = await getT(); const me = await currentUser(); if (!me) return Response.json({ error: t("Нужен вход") }, { status: 401 }); const format = new URL(req.url).searchParams.get("format") === "csv" ? "csv" : "jsonl"; const body = await exportConnectionJournal(db, me.id, format); const day = new Date().toISOString().slice(0, 10); return new Response(body, { headers: { "content-type": format === "csv" ? "text/csv; charset=utf-8" : "application/x-ndjson; charset=utf-8", "content-disposition": `attachment; filename="connections-journal-${day}.${format}"`, "cache-control": "no-store", "x-content-type-options": "nosniff", }, }); }