import type { APIRoute } from "astro"; import { getAllAttachments, setAttachment } from "../../lib/thread-store"; export const GET: APIRoute = async () => { try { const attachments = await getAllAttachments(); return new Response(JSON.stringify(attachments), { headers: { "Content-Type": "application/json" }, }); } catch (err: any) { return new Response(JSON.stringify({ error: err.message }), { status: 500, headers: { "Content-Type": "application/json" }, }); } }; export const POST: APIRoute = async ({ request }) => { try { const { threadId, linearIssue } = await request.json(); if (!threadId || !linearIssue) { return new Response( JSON.stringify({ error: "threadId and linearIssue required" }), { status: 400, headers: { "Content-Type": "application/json" } } ); } await setAttachment(threadId, linearIssue); return new Response(JSON.stringify({ ok: true }), { headers: { "Content-Type": "application/json" }, }); } catch (err: any) { return new Response(JSON.stringify({ error: err.message }), { status: 500, headers: { "Content-Type": "application/json" }, }); } };