@@ -10,6 +10,9 @@ import { NextRequest, NextResponse } from "next/server";
1010
1111export const runtime = "edge" ;
1212
13+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14+ type SupabaseClientInstance = any ;
15+
1316const STORY_WIDTH = 1080 ;
1417const STORY_HEIGHT = 1920 ;
1518
@@ -73,8 +76,19 @@ const buildMetricsFromAxes = (axes: VibeAxes): ShareCardMetric[] => {
7376 ] ;
7477} ;
7578
79+ interface UserProfileRow {
80+ axes_json ?: unknown ;
81+ cards_json ?: unknown ;
82+ persona_id ?: string ;
83+ persona_name ?: string | null ;
84+ persona_tagline ?: string | null ;
85+ persona_confidence ?: string | null ;
86+ total_commits ?: number | null ;
87+ total_repos ?: number | null ;
88+ }
89+
7690async function buildProfileStory (
77- supabase : ReturnType < typeof createSupabaseServerClient > ,
91+ supabase : SupabaseClientInstance ,
7892 userId : string ,
7993 appUrl : string
8094) : Promise < StoryData | null > {
@@ -86,27 +100,30 @@ async function buildProfileStory(
86100 . eq ( "user_id" , userId )
87101 . maybeSingle ( ) ;
88102
89- if ( ! profile || typeof profile !== "object" ) return null ;
103+ const profileRow = ( profile ?? null ) as UserProfileRow | null ;
104+ if ( ! profileRow ) return null ;
90105
91- const axes = isVibeAxes ( profile . axes_json ) ? profile . axes_json : null ;
106+ const axes = isVibeAxes ( profileRow . axes_json ) ? profileRow . axes_json : null ;
92107 const metrics = axes ? buildMetricsFromAxes ( axes ) : [ ] ;
93- const highlight = parseCardsHighlight ( profile . cards_json ) ;
94- const colors = STORY_THEMES [ profile . persona_id ?? "" ] ?? DEFAULT_THEME ;
108+ const highlight = parseCardsHighlight ( profileRow . cards_json ) ;
109+ const colors = STORY_THEMES [ profileRow . persona_id ?? "" ] ?? DEFAULT_THEME ;
95110 const subhead =
96- profile . persona_tagline ?. trim ( ) . length ? profile . persona_tagline : `${ profile . persona_confidence } confidence` ;
111+ profileRow . persona_tagline ?. trim ( ) . length
112+ ? profileRow . persona_tagline
113+ : `${ profileRow . persona_confidence ?? "medium" } confidence` ;
97114 const stats = [
98- `${ profile . total_commits ?. toLocaleString ( ) ?? "0" } commits` ,
99- `${ profile . total_repos ?? 0 } repos included` ,
115+ `${ profileRow . total_commits ?. toLocaleString ( ) ?? "0" } commits` ,
116+ `${ profileRow . total_repos ?? 0 } repos included` ,
100117 ] ;
101118 const topAxes = axes ? formatAxesList ( axes ) : [ ] ;
102119
103120 return {
104121 headline : "My Vibed Profile" ,
105122 subhead,
106- personaName : profile . persona_name ?? "Vibe Coder" ,
123+ personaName : profileRow . persona_name ?? "Vibe Coder" ,
107124 personaTagline : subhead ,
108- personaId : profile . persona_id ?? "balanced_builder" ,
109- personaConfidence : profile . persona_confidence ?? "medium" ,
125+ personaId : profileRow . persona_id ?? "balanced_builder" ,
126+ personaConfidence : profileRow . persona_confidence ?? "medium" ,
110127 metrics : metrics . length ? metrics : stats . slice ( 0 , 4 ) . map ( ( value , idx ) => ( { label : [ "Commits" , "Repos" , "Profile" , "Vibes" ] [ idx ] ?? `Stat ${ idx + 1 } ` , value } ) ) ,
111128 highlight,
112129 topAxes,
@@ -117,7 +134,7 @@ async function buildProfileStory(
117134}
118135
119136async function buildJobStory (
120- supabase : ReturnType < typeof createSupabaseServerClient > ,
137+ supabase : SupabaseClientInstance ,
121138 userId : string ,
122139 jobId : string ,
123140 appUrl : string
@@ -414,15 +431,16 @@ const renderStoryImage = async (story: StoryData, qrDataUrl: string) => {
414431
415432export async function GET (
416433 request : NextRequest ,
417- { params } : { params : { userId : string } }
434+ { params } : { params : Promise < { userId : string } > }
418435) {
419436 const appUrl = process . env . NEXT_PUBLIC_APP_URL ?? "https://www.vibed.app" ;
420437 const supabase = await createSupabaseServerClient ( ) ;
421438 const {
422439 data : { user } ,
423440 } = await supabase . auth . getUser ( ) ;
424441
425- if ( ! user || user . id !== params . userId ) {
442+ const { userId } = await params ;
443+ if ( ! user || user . id !== userId ) {
426444 return NextResponse . json ( { error : "unauthorized" } , { status : 401 } ) ;
427445 }
428446
0 commit comments