Improve errors and description of the Zod object responsible for parsing the Supabase keys.

This commit is contained in:
gbuomprisco
2025-01-13 02:33:58 +07:00
parent ec6f39579d
commit f7a5202c51

View File

@@ -6,8 +6,16 @@ import { z } from 'zod';
export function getSupabaseClientKeys() {
return z
.object({
url: z.string().min(1),
anonKey: z.string().min(1),
url: z.string({
description: `This is the URL of your hosted Supabase instance. Please provide the variable NEXT_PUBLIC_SUPABASE_URL.`,
required_error: `Please provide the variable NEXT_PUBLIC_SUPABASE_URL`,
}),
anonKey: z
.string({
description: `This is the anon key provided by Supabase. It is a public key used client-side. Please provide the variable NEXT_PUBLIC_SUPABASE_ANON_KEY.`,
required_error: `Please provide the variable NEXT_PUBLIC_SUPABASE_ANON_KEY`,
})
.min(1),
})
.parse({
url: process.env.NEXT_PUBLIC_SUPABASE_URL,