File size: 586 Bytes
7f6dd09 | 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 | import { createClient } from "@supabase/supabase-js";
import config from "../config.js";
let supabase = null;
function getClient() {
if (!supabase) {
if (
!config.supabaseUrl ||
config.supabaseUrl === "your_supabase_url_here"
) {
throw new Error("SUPABASE_URL is not configured in .env");
}
supabase = createClient(config.supabaseUrl, config.supabaseServiceKey);
}
return supabase;
}
// Proxy so callers can do `supabase.from(...)` directly
export default new Proxy(
{},
{
get(_, prop) {
return getClient()[prop];
},
},
);
|