From 7f4dc5c67b3ede732e666965b58e338eb2764daa Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sun, 9 Nov 2025 07:42:14 +0000 Subject: [PATCH] Prettier format pending files --- api/discord/oauth/callback.ts | 101 +++++++++++------- api/discord/oauth/start.ts | 4 +- api/discord/verify-code.ts | 14 ++- client/components/ArmSwitcher.tsx | 1 - client/components/ArmSwitcherModal.tsx | 27 +++-- .../admin/AdminDiscordDiagnostic.tsx | 13 ++- client/pages/DiscordVerify.tsx | 22 ++-- server/index.ts | 21 ++-- 8 files changed, 131 insertions(+), 72 deletions(-) diff --git a/api/discord/oauth/callback.ts b/api/discord/oauth/callback.ts index bf35ef16..8b869293 100644 --- a/api/discord/oauth/callback.ts +++ b/api/discord/oauth/callback.ts @@ -49,19 +49,22 @@ export default async function handler(req: any, res: any) { const redirectUri = `${process.env.VITE_API_BASE || "https://aethex.dev"}/api/discord/oauth/callback`; // Exchange code for access token - const tokenResponse = await fetch("https://discord.com/api/v10/oauth2/token", { - method: "POST", - headers: { - "Content-Type": "application/x-www-form-urlencoded", + const tokenResponse = await fetch( + "https://discord.com/api/v10/oauth2/token", + { + method: "POST", + headers: { + "Content-Type": "application/x-www-form-urlencoded", + }, + body: new URLSearchParams({ + client_id: clientId, + client_secret: clientSecret, + grant_type: "authorization_code", + code, + redirect_uri: redirectUri, + }).toString(), }, - body: new URLSearchParams({ - client_id: clientId, - client_secret: clientSecret, - grant_type: "authorization_code", - code, - redirect_uri: redirectUri, - }).toString(), - }); + ); if (!tokenResponse.ok) { const errorData = await tokenResponse.json(); @@ -115,19 +118,23 @@ export default async function handler(req: any, res: any) { } else { // Create new user // First create auth user - const { data: authData, error: authError } = await supabase.auth.admin.createUser({ - email: discordUser.email, - email_confirm: true, - user_metadata: { - full_name: discordUser.username, - avatar_url: discordUser.avatar - ? `https://cdn.discordapp.com/avatars/${discordUser.id}/${discordUser.avatar}.png` - : null, - }, - }); + const { data: authData, error: authError } = + await supabase.auth.admin.createUser({ + email: discordUser.email, + email_confirm: true, + user_metadata: { + full_name: discordUser.username, + avatar_url: discordUser.avatar + ? `https://cdn.discordapp.com/avatars/${discordUser.id}/${discordUser.avatar}.png` + : null, + }, + }); if (authError || !authData.user) { - console.error("[Discord OAuth] Auth user creation failed:", authError); + console.error( + "[Discord OAuth] Auth user creation failed:", + authError, + ); return res.redirect("/login?error=auth_create"); } @@ -135,17 +142,22 @@ export default async function handler(req: any, res: any) { isNewUser = true; // Create user profile - const { error: profileError } = await supabase.from("user_profiles").insert({ - id: userId, - email: discordUser.email, - full_name: discordUser.username, - avatar_url: discordUser.avatar - ? `https://cdn.discordapp.com/avatars/${discordUser.id}/${discordUser.avatar}.png` - : null, - }); + const { error: profileError } = await supabase + .from("user_profiles") + .insert({ + id: userId, + email: discordUser.email, + full_name: discordUser.username, + avatar_url: discordUser.avatar + ? `https://cdn.discordapp.com/avatars/${discordUser.id}/${discordUser.avatar}.png` + : null, + }); if (profileError) { - console.error("[Discord OAuth] Profile creation failed:", profileError); + console.error( + "[Discord OAuth] Profile creation failed:", + profileError, + ); return res.redirect("/login?error=profile_create"); } } @@ -164,9 +176,10 @@ export default async function handler(req: any, res: any) { } // Generate session token - const { data: sessionData, error: sessionError } = await supabase.auth.admin.createSession({ - user_id: userId, - }); + const { data: sessionData, error: sessionError } = + await supabase.auth.admin.createSession({ + user_id: userId, + }); if (sessionError || !sessionData.session) { console.error("[Discord OAuth] Session creation failed:", sessionError); @@ -174,17 +187,25 @@ export default async function handler(req: any, res: any) { } // Redirect to next page with session - const nextPath = state && typeof state === "string" && state.startsWith("/") ? state : isNewUser ? "/onboarding" : "/dashboard"; - const redirectUrl = new URL(nextPath, process.env.VITE_API_BASE || "https://aethex.dev"); - + const nextPath = + state && typeof state === "string" && state.startsWith("/") + ? state + : isNewUser + ? "/onboarding" + : "/dashboard"; + const redirectUrl = new URL( + nextPath, + process.env.VITE_API_BASE || "https://aethex.dev", + ); + // Set cookies for session (similar to how Supabase does it) res.setHeader( "Set-Cookie", - `sb-access-token=${sessionData.session.access_token}; Path=/; HttpOnly; Secure; SameSite=Lax` + `sb-access-token=${sessionData.session.access_token}; Path=/; HttpOnly; Secure; SameSite=Lax`, ); res.setHeader( "Set-Cookie", - `sb-refresh-token=${sessionData.session.refresh_token}; Path=/; HttpOnly; Secure; SameSite=Lax` + `sb-refresh-token=${sessionData.session.refresh_token}; Path=/; HttpOnly; Secure; SameSite=Lax`, ); res.redirect(redirectUrl.toString()); diff --git a/api/discord/oauth/start.ts b/api/discord/oauth/start.ts index 4197d703..f8083bf9 100644 --- a/api/discord/oauth/start.ts +++ b/api/discord/oauth/start.ts @@ -13,10 +13,10 @@ export default function handler(req: any, res: any) { } const redirectUri = `${process.env.VITE_API_BASE || "https://aethex.dev"}/api/discord/oauth/callback`; - + // Get the next URL from query params (where to redirect after login) const next = req.query.state || "/dashboard"; - + const params = new URLSearchParams({ client_id: clientId, redirect_uri: redirectUri, diff --git a/api/discord/verify-code.ts b/api/discord/verify-code.ts index 9e80bc4b..33c8084c 100644 --- a/api/discord/verify-code.ts +++ b/api/discord/verify-code.ts @@ -12,7 +12,9 @@ export default async function handler(req: any, res: any) { const { verification_code, user_id } = req.body; if (!verification_code || !user_id) { - return res.status(400).json({ message: "Missing verification code or user ID" }); + return res + .status(400) + .json({ message: "Missing verification code or user ID" }); } const supabaseUrl = process.env.VITE_SUPABASE_URL; @@ -35,7 +37,8 @@ export default async function handler(req: any, res: any) { if (verifyError || !verification) { return res.status(400).json({ - message: "Invalid or expired verification code. Please try /verify again.", + message: + "Invalid or expired verification code. Please try /verify again.", }); } @@ -50,7 +53,8 @@ export default async function handler(req: any, res: any) { if (existingLink && existingLink.user_id !== user_id) { return res.status(400).json({ - message: "This Discord account is already linked to another AeThex account.", + message: + "This Discord account is already linked to another AeThex account.", }); } @@ -63,7 +67,9 @@ export default async function handler(req: any, res: any) { if (linkError) { console.error("[Discord Verify] Link creation failed:", linkError); - return res.status(500).json({ message: "Failed to link Discord account" }); + return res + .status(500) + .json({ message: "Failed to link Discord account" }); } // Delete used verification code diff --git a/client/components/ArmSwitcher.tsx b/client/components/ArmSwitcher.tsx index a0d24142..2544413a 100644 --- a/client/components/ArmSwitcher.tsx +++ b/client/components/ArmSwitcher.tsx @@ -166,7 +166,6 @@ export default function ArmSwitcher() { onClose={() => setIsModalOpen(false)} /> - ); } diff --git a/client/components/ArmSwitcherModal.tsx b/client/components/ArmSwitcherModal.tsx index cf104797..d0da03ac 100644 --- a/client/components/ArmSwitcherModal.tsx +++ b/client/components/ArmSwitcherModal.tsx @@ -94,7 +94,8 @@ const ARM_DESCRIPTIONS: Record = { gameforge: "Game Development - Shipping games at the speed of thought with monthly cycles", corp: "Enterprise Solutions - Consulting for large-scale transformations", - foundation: "Community & Education - Building open-source and talent pipelines", + foundation: + "Community & Education - Building open-source and talent pipelines", devlink: "Professional Networking - LinkedIn for Roblox developers and creators", nexus: "Talent Marketplace - Cross-arm collaboration and opportunities", @@ -128,7 +129,9 @@ export default function ArmSwitcherModal({ onClose(); }; - const selectedArmData = selectedArm ? ARMS.find((a) => a.id === selectedArm) : null; + const selectedArmData = selectedArm + ? ARMS.find((a) => a.id === selectedArm) + : null; if (!isOpen) return null; @@ -179,7 +182,9 @@ export default function ArmSwitcherModal({ {ARM_DESCRIPTIONS[arm.id]}

-
+
))} @@ -213,13 +218,17 @@ export default function ArmSwitcherModal({
{/* Features */} -
+

What you'll get:

  • - + @@ -227,7 +236,9 @@ export default function ArmSwitcherModal({
  • - + 🚀 @@ -235,7 +246,9 @@ export default function ArmSwitcherModal({
  • - + 🎯 diff --git a/client/components/admin/AdminDiscordDiagnostic.tsx b/client/components/admin/AdminDiscordDiagnostic.tsx index f7576a20..720d608d 100644 --- a/client/components/admin/AdminDiscordDiagnostic.tsx +++ b/client/components/admin/AdminDiscordDiagnostic.tsx @@ -1,5 +1,10 @@ import { useState, useEffect } from "react"; -import { AlertCircle, CheckCircle, AlertTriangle, RefreshCw } from "lucide-react"; +import { + AlertCircle, + CheckCircle, + AlertTriangle, + RefreshCw, +} from "lucide-react"; interface DiagnosticData { timestamp: string; @@ -46,7 +51,7 @@ export default function AdminDiscordDiagnostic() { setDiagnostic(data); } catch (err) { setError( - err instanceof Error ? err.message : "Failed to fetch diagnostic" + err instanceof Error ? err.message : "Failed to fetch diagnostic", ); } finally { setLoading(false); @@ -60,7 +65,9 @@ export default function AdminDiscordDiagnostic() { return (
    -

    Discord Configuration Diagnostic

    +

    + Discord Configuration Diagnostic +

    @@ -153,8 +156,15 @@ export default function DiscordVerify() {

    1. Open Discord
    2. -
    3. Go to any server where the AeThex bot is installed
    4. -
    5. Type /verify
    6. +
    7. + Go to any server where the AeThex bot is installed +
    8. +
    9. + Type{" "} + + /verify + +
    10. Copy the 6-digit code from the bot's response
    @@ -213,8 +223,8 @@ export default function DiscordVerify() { {/* Info Box */}

    - 💡 Tip: You can also sign in directly with Discord - on the login page if you're creating a new account. + 💡 Tip: You can also sign in directly with + Discord on the login page if you're creating a new account.

diff --git a/server/index.ts b/server/index.ts index 3ca4500e..2049cc10 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1500,21 +1500,21 @@ export function createServer() { // Add recommendations based on validation if (!botToken) { diagnostics.recommendations.push( - "❌ DISCORD_BOT_TOKEN not set. Set it in environment variables." + "❌ DISCORD_BOT_TOKEN not set. Set it in environment variables.", ); } else if ((botToken?.length || 0) < 20) { diagnostics.recommendations.push( - `❌ DISCORD_BOT_TOKEN appears invalid (length: ${botToken?.length}). Should be 60+ characters.` + `❌ DISCORD_BOT_TOKEN appears invalid (length: ${botToken?.length}). Should be 60+ characters.`, ); } else { diagnostics.recommendations.push( - "✅ DISCORD_BOT_TOKEN format looks valid" + "✅ DISCORD_BOT_TOKEN format looks valid", ); } if (!clientId) { diagnostics.recommendations.push( - "❌ DISCORD_CLIENT_ID not set. Set it to your application's ID." + "❌ DISCORD_CLIENT_ID not set. Set it to your application's ID.", ); } else { diagnostics.recommendations.push("✅ DISCORD_CLIENT_ID is set"); @@ -1522,7 +1522,7 @@ export function createServer() { if (!publicKey) { diagnostics.recommendations.push( - "❌ DISCORD_PUBLIC_KEY not set. Needed for signature verification." + "❌ DISCORD_PUBLIC_KEY not set. Needed for signature verification.", ); } else { diagnostics.recommendations.push("✅ DISCORD_PUBLIC_KEY is set"); @@ -1537,22 +1537,25 @@ export function createServer() { headers: { Authorization: `Bot ${botToken}`, }, - } + }, ); diagnostics.testRequest = { ...diagnostics.testRequest, - status: testResponse.status === 200 ? "✅ Success" : `❌ Failed (${testResponse.status})`, + status: + testResponse.status === 200 + ? "✅ Success" + : `❌ Failed (${testResponse.status})`, responseCode: testResponse.status, }; if (testResponse.status === 401) { diagnostics.recommendations.push( - "❌ Token authentication failed (401). The token may be invalid or revoked." + "❌ Token authentication failed (401). The token may be invalid or revoked.", ); } else if (testResponse.status === 200) { diagnostics.recommendations.push( - "✅ Token authentication successful with Discord API!" + "✅ Token authentication successful with Discord API!", ); } } catch (error) {