SPB Git
915 B · 12 lines typescript
1import { guarded } from "@/lib/api";2import { sql } from "@/lib/db";34export const GET = guarded(async (req) => {5  const rows = await sql`SELECT id, category, content, source, status, confidence, project_id, source_conversation_id, created_at, updated_at FROM memories ORDER BY created_at`;6  if (req.nextUrl.searchParams.get("format") === "md") {7    const md = [`# Mémoire — Chat SPBoucher AI`, `_${rows.length} éléments, exporté le ${new Date().toLocaleString("fr-CA")}_`, "", ...rows.map(r => `- **[${r.category}]** ${r.content} _(${r.status}, ${r.source})_`)].join("\n");8    return new Response(md, { headers: { "content-type": "text/markdown; charset=utf-8", "content-disposition": 'attachment; filename="memoire.md"' } });9  }10  return new Response(JSON.stringify(rows, null, 2), { headers: { "content-type": "application/json", "content-disposition": 'attachment; filename="memoire.json"' } });11});12
Files · main
Menu

Theme