import { withUser, json, ApiError } from "@/lib/api"; import { listShares, revokeShareById } from "@/lib/conversations/service"; import { LIMITS } from "@/lib/rate-limit"; export const dynamic = "force-dynamic"; /** GET /api/shares → `{ shares: ShareLinkItem[] }` — every active public link of the user (Settings → Data). */ export const GET = withUser(async ({ user }) => json({ shares: await listShares(user.id) }), { limit: { ...LIMITS.search, key: "shares-list" } }); /** DELETE /api/shares?id= → `{ ok: true }` — revoke one link. */ export const DELETE = withUser( async ({ req, user }) => { const id = new URL(req.url).searchParams.get("id")?.trim(); if (!id) throw new ApiError(400, "Missing share id"); await revokeShareById(user.id, id); return json({ ok: true }); }, { limit: { ...LIMITS.share, key: "shares-revoke" } }, );