From b2ff830a9bf45cb063ae4f1e47779b79c843a8bc Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Tue, 14 Oct 2025 04:26:08 +0000 Subject: [PATCH] Add opportunities applications API endpoint cgen-2b632b71ce004d44801a3daf6eccd00a --- server/index.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/server/index.ts b/server/index.ts index 14ee223b..6af5a5e4 100644 --- a/server/index.ts +++ b/server/index.ts @@ -371,6 +371,31 @@ export function createServer() { res.status(500).json({ error: e?.message || String(e) }); } }); + + app.get("/api/opportunities/applications", async (req, res) => { + const requester = String(req.query.email || "").toLowerCase(); + if (!requester || requester !== ownerEmail) { + return res.status(403).json({ error: "forbidden" }); + } + try { + const { data, error } = await adminSupabase + .from("applications") + .select("*") + .order("submitted_at", { ascending: false }) + .limit(200); + if (error) { + if (isTableMissing(error)) { + return res.json([]); + } + return res.status(500).json({ error: error.message }); + } + return res.json(data || []); + } catch (e: any) { + return res + .status(500) + .json({ error: e?.message || String(e) }); + } + }); } catch (e) { console.warn("Admin API not initialized:", e); }