-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_utils.js
More file actions
29 lines (24 loc) · 900 Bytes
/
db_utils.js
File metadata and controls
29 lines (24 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const fs = require('fs');
const path = require('path');
const { createClient } = require('@supabase/supabase-js');
const dotenv = require('dotenv');
// Load environment variables from .env file
dotenv.config();
// Supabase credentials from env
const supabaseUrl = process.env.supabase_server;
const supabaseServiceKey = process.env.supabase_service_key;
// Initialize Supabase client with service role key (admin access)
function getSupabaseClient() {
if (!supabaseUrl || !supabaseServiceKey) {
console.error('Error: Supabase credentials not found in environment variables.');
console.error('Make sure you have a .env file with supabase_server and supabase_service_key defined.');
process.exit(1);
}
return createClient(supabaseUrl, supabaseServiceKey);
}
// Export utility functions and variables
module.exports = {
getSupabaseClient,
supabaseUrl,
supabaseServiceKey
};