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.
17 lines
374 B
TypeScript
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,
|
|
});
|
|
}
|