Final push before system formatting
This commit is contained in:
36
AppDev/ikt205_2026_18_study_sprint/source/lib/supabase.ts
Normal file
36
AppDev/ikt205_2026_18_study_sprint/source/lib/supabase.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
import * as SecureStore from 'expo-secure-store';
|
||||
import 'react-native-url-polyfill/auto';
|
||||
|
||||
const supabaseUrl = process.env.EXPO_PUBLIC_SUPABASE_URL!
|
||||
const supabaseKey = process.env.EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY!
|
||||
|
||||
if (!supabaseUrl) {
|
||||
throw new Error('Missing EXPO_PUBLIC_SUPABASE_URL');
|
||||
}
|
||||
|
||||
if (!supabaseKey) {
|
||||
throw new Error('Missing EXPO_PUBLIC_SUPABASE_PUBLISHABLE_KEY');
|
||||
}
|
||||
|
||||
const SecureStoreAdapter = {
|
||||
getItem: async (key: string) => {
|
||||
return await SecureStore.getItemAsync(key);
|
||||
},
|
||||
setItem: async (key: string, value: string) => {
|
||||
await SecureStore.setItemAsync(key, value);
|
||||
},
|
||||
removeItem: async (key: string) => {
|
||||
await SecureStore.deleteItemAsync(key);
|
||||
},
|
||||
};
|
||||
|
||||
export const supabase = createClient(supabaseUrl, supabaseKey, {
|
||||
auth: {
|
||||
storage: SecureStoreAdapter,
|
||||
autoRefreshToken: true,
|
||||
persistSession: true,
|
||||
detectSessionInUrl: false,
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user