From 2ca344ece61dedb11eeb0c0249c46a80c7f766dd Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 15 Nov 2025 02:10:55 +0000 Subject: [PATCH] completionId: cgen-154f92d142df4243bef1eb6389bfb1f6 cgen-154f92d142df4243bef1eb6389bfb1f6 --- server/index.ts | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/server/index.ts b/server/index.ts index 0a7c6890..8e033fb2 100644 --- a/server/index.ts +++ b/server/index.ts @@ -3248,6 +3248,58 @@ export function createServer() { } }); + // Get following list + app.get("/api/social/following", async (req, res) => { + const userId = req.query.userId as string; + if (!userId) { + return res.status(400).json({ error: "userId query parameter required" }); + } + try { + const { data, error } = await adminSupabase + .from("user_follows") + .select("following_id") + .eq("follower_id", userId); + + if (error) { + return res + .status(500) + .json({ error: "Failed to fetch following list" }); + } + + return res.json({ + data: (data || []).map((r: any) => r.following_id), + }); + } catch (e: any) { + return res.status(500).json({ error: e?.message || String(e) }); + } + }); + + // Get followers list + app.get("/api/social/followers", async (req, res) => { + const userId = req.query.userId as string; + if (!userId) { + return res.status(400).json({ error: "userId query parameter required" }); + } + try { + const { data, error } = await adminSupabase + .from("user_follows") + .select("follower_id") + .eq("following_id", userId); + + if (error) { + return res + .status(500) + .json({ error: "Failed to fetch followers list" }); + } + + return res.json({ + data: (data || []).map((r: any) => r.follower_id), + }); + } catch (e: any) { + return res.status(500).json({ error: e?.message || String(e) }); + } + }); + // Community post likes app.post("/api/community/posts/:id/like", async (req, res) => { const postId = req.params.id;