import { requireUser } from "@/lib/auth"; import { exportAll } from "@/lib/store"; // GET /api/export — full JSON export of the dashboard's local data. export async function GET(req: Request) { const userId = await requireUser(req); const payload = { version: 1, app: process.env.APP_SLUG ?? "personal-dashboard", exportedAt: new Date().toISOString(), userId, data: exportAll(), }; const filename = `${payload.app}-${payload.exportedAt.slice(0, 10)}.json`; return new Response(JSON.stringify(payload, null, 2), { headers: { "Content-Type": "application/json", "Content-Disposition": `attachment; filename="${filename}"`, }, }); }