Files
myeasycms-v2/packages/supabase/src/get-supabase-client-keys.ts
giancarlo 87e8376af6 Refactor key access and role warning in Supabase clients
The update simplifies accessing environment keys and role warnings in Supabase clients by moving them to new functions 'getSupabaseClientKeys' and 'getServiceRoleKey'. The redundancy in the code is reduced promoting clearer and more maintainable code. The '@epic-web/invariant' import has been removed from files as it is no longer needed.
2024-04-13 12:57:56 +08:00

17 lines
374 B
TypeScript

import { z } from 'zod';
/**
* Returns and validates the Supabase client keys from the environment.
*/
export function getSupabaseClientKeys() {
return z
.object({
url: z.string().min(1),
anonKey: z.string().min(1),
})
.parse({
url: process.env.NEXT_PUBLIC_SUPABASE_URL,
anonKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
});
}