From 312072a869aacbac57f44689302a7d83a19eefaa Mon Sep 17 00:00:00 2001 From: sirpiglr <49359077-sirpiglr@users.noreply.replit.com> Date: Mon, 8 Dec 2025 01:29:26 +0000 Subject: [PATCH] Fix various type errors in API files to ensure proper functionality Resolves TypeScript errors across multiple API files, including Stripe API version mismatches and incorrect type assertions for request data, enabling successful Vercel builds. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9203795e-937a-4306-b81d-b4d5c78c240e Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: c124cc2e-6c8d-4ca4-80d3-5d34ca7aed66 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7c94b7a0-29c7-4f2e-94ef-44b2153872b7/9203795e-937a-4306-b81d-b4d5c78c240e/qPXTzuE Replit-Helium-Checkpoint-Created: true --- api/auth/exchange-token.ts | 2 +- api/auth/foundation-callback.ts | 1 + api/ethos/licensing-notifications.ts | 6 +++--- api/gameforge/builds.ts | 2 +- api/games/roblox-auth.ts | 2 +- api/github/oauth/callback.ts | 4 ++-- api/integrations/fourthwall.ts | 2 +- api/nexus/payments/confirm-payment.ts | 2 +- api/nexus/payments/create-intent.ts | 2 +- api/nexus/payments/payout-setup.ts | 2 +- api/nexus/payments/webhook.ts | 2 +- api/user/arm-affiliations.ts | 2 +- 12 files changed, 15 insertions(+), 14 deletions(-) diff --git a/api/auth/exchange-token.ts b/api/auth/exchange-token.ts index 142169dc..aab91363 100644 --- a/api/auth/exchange-token.ts +++ b/api/auth/exchange-token.ts @@ -47,7 +47,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { }); } - const tokenData = await tokenResponse.json(); + const tokenData = (await tokenResponse.json()) as { access_token?: string; user?: { id: string } }; if (!tokenData.access_token) { return res.status(400).json({ error: "No access token in response" }); diff --git a/api/auth/foundation-callback.ts b/api/auth/foundation-callback.ts index 68aa47e1..7cc10bf8 100644 --- a/api/auth/foundation-callback.ts +++ b/api/auth/foundation-callback.ts @@ -20,6 +20,7 @@ interface FoundationTokenResponse { id: string; email: string; username: string; + full_name?: string; profile_complete: boolean; }; } diff --git a/api/ethos/licensing-notifications.ts b/api/ethos/licensing-notifications.ts index 19079f8d..c196f865 100644 --- a/api/ethos/licensing-notifications.ts +++ b/api/ethos/licensing-notifications.ts @@ -209,9 +209,9 @@ export default async function handler(req: any, res: any) { return res.status(404).json({ error: "Agreement not found" }); } - const licensee = agreement.user_profiles?.[0]; - const artist = agreement.ethos_tracks?.user_profiles?.[0]; - const trackTitle = agreement.ethos_tracks?.title; + const licensee = (agreement as any).user_profiles?.[0]; + const artist = (agreement as any).ethos_tracks?.user_profiles?.[0]; + const trackTitle = (agreement as any).ethos_tracks?.title; if (!licensee?.email) { return res.status(400).json({ error: "Licensee email not found" }); diff --git a/api/gameforge/builds.ts b/api/gameforge/builds.ts index 01cbd3ca..583ebb9b 100644 --- a/api/gameforge/builds.ts +++ b/api/gameforge/builds.ts @@ -132,7 +132,7 @@ export default async function handler(req: any, res: any) { .eq("id", id) .single(); - if (build?.gameforge_projects?.lead_id !== userId) { + if ((build?.gameforge_projects as any)?.lead_id !== userId) { return res .status(403) .json({ error: "Only project lead can update builds" }); diff --git a/api/games/roblox-auth.ts b/api/games/roblox-auth.ts index d8d6dee9..854736df 100644 --- a/api/games/roblox-auth.ts +++ b/api/games/roblox-auth.ts @@ -102,7 +102,7 @@ export default async function handler(req: VercelRequest, res: VercelResponse) { success: true, game_token: gameToken, user_id: userData.id, - username: userData.username || roblox_username, + username: (userData as any).username || roblox_username, expires_in: 86400, // seconds }); } catch (error: any) { diff --git a/api/github/oauth/callback.ts b/api/github/oauth/callback.ts index e51ebc38..7c1299f1 100644 --- a/api/github/oauth/callback.ts +++ b/api/github/oauth/callback.ts @@ -179,8 +179,8 @@ export default async function handler(req: any, res: any) { }); if (emailResponse.ok) { - const emails = await emailResponse.json(); - const primaryEmail = emails.find((e: any) => e.primary); + const emails = (await emailResponse.json()) as Array<{ email: string; primary: boolean }>; + const primaryEmail = emails.find((e) => e.primary); email = primaryEmail?.email || emails[0]?.email; } } diff --git a/api/integrations/fourthwall.ts b/api/integrations/fourthwall.ts index c8988479..9bef8781 100644 --- a/api/integrations/fourthwall.ts +++ b/api/integrations/fourthwall.ts @@ -136,7 +136,7 @@ async function handleSyncProducts(req: any, res: any) { throw new Error(`Failed to fetch products: ${response.statusText}`); } - const data = await response.json(); + const data = (await response.json()) as { products?: FourthwallProduct[] }; const products: FourthwallProduct[] = data.products || []; // Sync products to Supabase diff --git a/api/nexus/payments/confirm-payment.ts b/api/nexus/payments/confirm-payment.ts index da49024a..e987d85d 100644 --- a/api/nexus/payments/confirm-payment.ts +++ b/api/nexus/payments/confirm-payment.ts @@ -3,7 +3,7 @@ import Stripe from "stripe"; import { getAdminClient } from "../../_supabase.js"; const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", { - apiVersion: "2024-11-20", + apiVersion: "2024-04-10", }); export default async function handler(req: VercelRequest, res: VercelResponse) { diff --git a/api/nexus/payments/create-intent.ts b/api/nexus/payments/create-intent.ts index a7385274..e4f7998e 100644 --- a/api/nexus/payments/create-intent.ts +++ b/api/nexus/payments/create-intent.ts @@ -3,7 +3,7 @@ import Stripe from "stripe"; import { getAdminClient } from "../../_supabase.js"; const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", { - apiVersion: "2024-11-20", + apiVersion: "2024-04-10", }); export default async function handler(req: VercelRequest, res: VercelResponse) { diff --git a/api/nexus/payments/payout-setup.ts b/api/nexus/payments/payout-setup.ts index b891dc72..bc31bcfe 100644 --- a/api/nexus/payments/payout-setup.ts +++ b/api/nexus/payments/payout-setup.ts @@ -3,7 +3,7 @@ import Stripe from "stripe"; import { getAdminClient } from "../../_supabase.js"; const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", { - apiVersion: "2024-11-20", + apiVersion: "2024-04-10", }); const apiBase = process.env.VITE_API_BASE || "https://aethex.dev"; diff --git a/api/nexus/payments/webhook.ts b/api/nexus/payments/webhook.ts index 8fcbfc03..7e58b242 100644 --- a/api/nexus/payments/webhook.ts +++ b/api/nexus/payments/webhook.ts @@ -3,7 +3,7 @@ import Stripe from "stripe"; import { getAdminClient } from "../../_supabase.js"; const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", { - apiVersion: "2024-11-20", + apiVersion: "2024-04-10", }); const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET || ""; diff --git a/api/user/arm-affiliations.ts b/api/user/arm-affiliations.ts index 3784f2fc..877f48ae 100644 --- a/api/user/arm-affiliations.ts +++ b/api/user/arm-affiliations.ts @@ -87,7 +87,7 @@ export default async (req: Request) => { // DELETE - Remove arm affiliation if (req.method === "DELETE") { - const body = await req.json(); + const body = (await req.json()) as { arm: string; affiliation_type?: string }; const { arm, affiliation_type } = body; if (!VALID_ARMS.includes(arm)) {