From 16de77fb35bfff95c2baa840fa76dc8bb71dd409 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 18 Oct 2025 21:03:33 +0000 Subject: [PATCH] Add staff users listing endpoint cgen-b486b439363240e992013fbe2cb1701c --- server/index.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/server/index.ts b/server/index.ts index 8d9318a5..9c330f35 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1180,6 +1180,30 @@ export function createServer() { } }); + // Staff: users search/listing + app.get("/api/staff/users", async (req, res) => { + const limit = Math.max(1, Math.min(50, Number(req.query.limit) || 20)); + const q = String(req.query.q || "").trim().toLowerCase(); + try { + const { data, error } = await adminSupabase + .from("user_profiles") + .select("id, username, full_name, avatar_url, user_type, created_at, updated_at") + .order("created_at", { ascending: false }) + .limit(limit); + if (error) return res.status(500).json({ error: error.message }); + let rows = (data || []) as any[]; + if (q) { + rows = rows.filter((r) => { + const name = String(r.full_name || r.username || "").toLowerCase(); + return name.includes(q); + }); + } + return res.json(rows); + } catch (e: any) { + return res.status(500).json({ error: e?.message || String(e) }); + } + }); + // Mentorship API app.get("/api/mentors", async (req, res) => { const limit = Math.max(1, Math.min(50, Number(req.query.limit) || 20));