@@ -2,7 +2,7 @@ import { createClient } from '@supabase/supabase-js';
22
33// These should be in your .env file
44const supabaseUrl = import . meta. env . VITE_SUPABASE_URL || '' ;
5- const supabasePublishableKey = import . meta. env . VITE_SUPABASE_PUBLISHABLE_KEY || '' ;
5+ const supabasePublishableKey = import . meta. env . VITE_SUPABASE_ANON_KEY || '' ;
66
77// Debug: Log the configuration (remove in production)
88if ( ! supabaseUrl || ! supabasePublishableKey ) {
@@ -143,7 +143,7 @@ export const supabaseFunctions = {
143143 const { data, error } = await supabase . functions . invoke ( 'analyze-stock' , {
144144 body : { ticker, date }
145145 } ) ;
146-
146+
147147 if ( error ) throw error ;
148148 return data ;
149149 } ,
@@ -153,7 +153,7 @@ export const supabaseFunctions = {
153153 const { data, error } = await supabase . functions . invoke ( 'analyze-portfolio' , {
154154 body : { tickers, date }
155155 } ) ;
156-
156+
157157 if ( error ) throw error ;
158158 return data ;
159159 }
@@ -164,7 +164,7 @@ export const supabaseHelpers = {
164164 // Get or create API settings for a user
165165 async getOrCreateApiSettings ( userId : string ) : Promise < ApiSettings | null > {
166166 console . log ( 'getOrCreateApiSettings called for user:' , userId ) ;
167-
167+
168168 try {
169169 // First try to get existing settings
170170 console . log ( 'Fetching api_settings for user:' , userId ) ;
@@ -180,7 +180,7 @@ export const supabaseHelpers = {
180180 console . log ( 'Found existing settings:' , existing ) ;
181181 return existing ;
182182 }
183-
183+
184184 // If no settings exist (PGRST116 error), create default ones
185185 if ( fetchError ?. code === 'PGRST116' ) {
186186 console . log ( 'No settings found, creating defaults...' ) ;
@@ -220,7 +220,7 @@ export const supabaseHelpers = {
220220 hint : fetchError ?. hint ,
221221 userId
222222 } ) ;
223-
223+
224224 // If it's a different error, still try to create settings
225225 console . log ( 'Attempting to create settings despite error...' ) ;
226226 const defaultSettings = {
@@ -291,10 +291,10 @@ export const supabaseHelpers = {
291291 try {
292292 // Set a timeout for the session check
293293 const sessionPromise = supabase . auth . getSession ( ) ;
294- const timeoutPromise = new Promise ( ( _ , reject ) =>
294+ const timeoutPromise = new Promise ( ( _ , reject ) =>
295295 setTimeout ( ( ) => reject ( new Error ( 'Session check timeout' ) ) , 5000 )
296296 ) ;
297-
297+
298298 const result = await Promise . race ( [ sessionPromise , timeoutPromise ] ) as any ;
299299 return result ;
300300 } catch ( error ) {
0 commit comments