From 7b6082adf79935fad4ec7dce8ffd7e978cd1e2c6 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sun, 28 Sep 2025 05:04:51 +0000 Subject: [PATCH] Prettier format pending files --- client/lib/supabase.ts | 2 +- client/pages/Dashboard.tsx | 12 ++++++-- client/pages/Onboarding.tsx | 7 +++-- server/index.ts | 56 +++++++++++++++++++++++++++---------- server/supabase.ts | 7 +++-- 5 files changed, 63 insertions(+), 21 deletions(-) diff --git a/client/lib/supabase.ts b/client/lib/supabase.ts index a40d713b..59d1fa0c 100644 --- a/client/lib/supabase.ts +++ b/client/lib/supabase.ts @@ -219,7 +219,7 @@ export const storage = supabase.storage; export const channel = supabase.channel; // Test function for debugging -;(window as any).testSupabase = async () => { +(window as any).testSupabase = async () => { console.log("🧪 Manual Supabase Test"); console.log("URL:", supabaseUrl); console.log("Key configured:", !!supabaseAnonKey); diff --git a/client/pages/Dashboard.tsx b/client/pages/Dashboard.tsx index 3bdc09f4..ccca17ea 100644 --- a/client/pages/Dashboard.tsx +++ b/client/pages/Dashboard.tsx @@ -51,7 +51,13 @@ import { export default function Dashboard() { const navigate = useNavigate(); - const { user, profile, loading: authLoading, updateProfile, profileComplete } = useAuth(); + const { + user, + profile, + loading: authLoading, + updateProfile, + profileComplete, + } = useAuth(); const [displayName, setDisplayName] = useState(""); const [locationInput, setLocationInput] = useState(""); const [bio, setBio] = useState(""); @@ -491,7 +497,9 @@ export default function Dashboard() { Level {profile?.level || 1} {profileComplete && ( - Profile Complete + + Profile Complete + )} diff --git a/client/pages/Onboarding.tsx b/client/pages/Onboarding.tsx index c5557d32..74094aa9 100644 --- a/client/pages/Onboarding.tsx +++ b/client/pages/Onboarding.tsx @@ -139,8 +139,11 @@ export default function Onboarding() { if (!ensureResp.ok) { const text = await ensureResp.text().catch(() => ""); let parsedError: any = undefined; - try { parsedError = JSON.parse(text); } catch {} - const message = parsedError?.error || text || `HTTP ${ensureResp.status}`; + try { + parsedError = JSON.parse(text); + } catch {} + const message = + parsedError?.error || text || `HTTP ${ensureResp.status}`; throw new Error(message); } diff --git a/server/index.ts b/server/index.ts index cbecc6c0..44dc5b1a 100644 --- a/server/index.ts +++ b/server/index.ts @@ -21,11 +21,16 @@ export function createServer() { try { app.get("/api/health", async (_req, res) => { try { - const { error } = await adminSupabase.from("user_profiles").select("count", { count: "exact", head: true }); - if (error) return res.status(500).json({ ok: false, error: error.message }); + const { error } = await adminSupabase + .from("user_profiles") + .select("count", { count: "exact", head: true }); + if (error) + return res.status(500).json({ ok: false, error: error.message }); return res.json({ ok: true }); } catch (e: any) { - return res.status(500).json({ ok: false, error: e?.message || String(e) }); + return res + .status(500) + .json({ ok: false, error: e?.message || String(e) }); } }); @@ -121,18 +126,29 @@ export function createServer() { const code: string = (error as any).code || ""; // Handle duplicate username - if (code === "23505" || message.includes("duplicate key") || message.includes("username")) { + if ( + code === "23505" || + message.includes("duplicate key") || + message.includes("username") + ) { const suffix = Math.random().toString(36).slice(2, 6); const newUsername = `${String(username || "user").slice(0, 20)}_${suffix}`; console.log("[API] retrying with unique username", newUsername); - attempt = await tryUpsert({ id, ...profile, username: newUsername }); + attempt = await tryUpsert({ + id, + ...profile, + username: newUsername, + }); error = normalizeError(attempt.error); } } if (error) { // Possible foreign key violation: auth.users missing - if ((error as any).code === "23503" || (error as any).message?.includes("foreign key")) { + if ( + (error as any).code === "23503" || + (error as any).message?.includes("foreign key") + ) { return res.status(400).json({ error: "User does not exist in authentication system. Please sign out and sign back in, then retry onboarding.", @@ -140,7 +156,9 @@ export function createServer() { } return res.status(500).json({ error: - (error as any).message || JSON.stringify(error) || "Unknown error", + (error as any).message || + JSON.stringify(error) || + "Unknown error", }); } @@ -153,12 +171,21 @@ export function createServer() { app.post("/api/interests", async (req, res) => { const { user_id, interests } = req.body || {}; - if (!user_id || !Array.isArray(interests)) return res.status(400).json({ error: "invalid payload" }); + if (!user_id || !Array.isArray(interests)) + return res.status(400).json({ error: "invalid payload" }); try { - await adminSupabase.from("user_interests").delete().eq("user_id", user_id); + await adminSupabase + .from("user_interests") + .delete() + .eq("user_id", user_id); if (interests.length) { - const rows = interests.map((interest: string) => ({ user_id, interest })); - const { error } = await adminSupabase.from("user_interests").insert(rows); + const rows = interests.map((interest: string) => ({ + user_id, + interest, + })); + const { error } = await adminSupabase + .from("user_interests") + .insert(rows); if (error) return res.status(500).json({ error: error.message }); } res.json({ ok: true }); @@ -170,9 +197,10 @@ export function createServer() { app.post("/api/achievements/award", async (req, res) => { const { user_id, achievement_names } = req.body || {}; if (!user_id) return res.status(400).json({ error: "user_id required" }); - const names: string[] = Array.isArray(achievement_names) && achievement_names.length - ? achievement_names - : ["Welcome to AeThex"]; + const names: string[] = + Array.isArray(achievement_names) && achievement_names.length + ? achievement_names + : ["Welcome to AeThex"]; try { const { data: achievements, error: aErr } = await adminSupabase .from("achievements") diff --git a/server/supabase.ts b/server/supabase.ts index 775eb490..848145b9 100644 --- a/server/supabase.ts +++ b/server/supabase.ts @@ -1,13 +1,16 @@ import { createClient } from "@supabase/supabase-js"; -const SUPABASE_URL = process.env.SUPABASE_URL || process.env.VITE_SUPABASE_URL || ""; +const SUPABASE_URL = + process.env.SUPABASE_URL || process.env.VITE_SUPABASE_URL || ""; const SUPABASE_SERVICE_ROLE = process.env.SUPABASE_SERVICE_ROLE || ""; if (!SUPABASE_URL) { console.warn("SUPABASE_URL not set for server"); } if (!SUPABASE_SERVICE_ROLE) { - console.warn("SUPABASE_SERVICE_ROLE not set for server (admin ops will fail)"); + console.warn( + "SUPABASE_SERVICE_ROLE not set for server (admin ops will fail)", + ); } export const adminSupabase = createClient(SUPABASE_URL, SUPABASE_SERVICE_ROLE, {