From fdbfebb01df3f55ff54cb5b25a3b3b144a37c4dc Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Mon, 10 Nov 2025 03:51:51 +0000 Subject: [PATCH] Add missing GET /api/blog endpoint cgen-2a66d3b40cfb464fa8871639d1133872 --- server/index.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/server/index.ts b/server/index.ts index 5d6d6db4..aea1ad94 100644 --- a/server/index.ts +++ b/server/index.ts @@ -2378,6 +2378,27 @@ export function createServer() { } }); + app.get("/api/blog", async (req, res) => { + const limit = Math.min(Number(req.query.limit) || 50, 200); + try { + const { data, error } = await adminSupabase + .from("blog_posts") + .select("*") + .order("published_at", { ascending: false }) + .limit(limit); + if (error) { + // Table might not exist yet, return empty array + if (error.message?.includes("does not exist")) { + return res.json([]); + } + return res.status(500).json({ error: error.message }); + } + res.json(data || []); + } catch (e: any) { + res.status(500).json({ error: e?.message || String(e) }); + } + }); + app.post("/api/blog", async (req, res) => { const p = req.body || {}; const row = {