mirror of
https://github.com/tiennm99/bsk.git
synced 2026-08-26 10:27:42 +00:00
- app/, components/, lib/, i18n/, tests/, proxy renamed via git mv - types carried into JSDoc: @template generics, @typedef aliases, /** @type */ casts where TS had as-casts or non-null assertions - role tuple keeps its const assertion; the db-enum drift guard now checks the tuple values against the generated enum type - use client/use server directives and server-only imports preserved - prettier-formatted; vitest suite unchanged
28 lines
878 B
JavaScript
28 lines
878 B
JavaScript
import { z } from "zod";
|
|
|
|
const clientSchema = z.object({
|
|
NEXT_PUBLIC_APP_ENV: z.enum(["dev", "preview", "prod"]).default("dev"),
|
|
NEXT_PUBLIC_SUPABASE_URL: z.url(),
|
|
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY: z.string().min(1),
|
|
});
|
|
|
|
const parsed = clientSchema.safeParse({
|
|
NEXT_PUBLIC_APP_ENV: process.env.NEXT_PUBLIC_APP_ENV,
|
|
NEXT_PUBLIC_SUPABASE_URL: process.env.NEXT_PUBLIC_SUPABASE_URL,
|
|
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY: process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY,
|
|
});
|
|
|
|
if (!parsed.success) {
|
|
const issues = Object.entries(parsed.error.flatten().fieldErrors)
|
|
.map(([k, v]) => ` ${k}: ${(v ?? []).join(", ")}`)
|
|
.join("\n");
|
|
throw new Error(`Invalid public environment variables:\n${issues}`);
|
|
}
|
|
|
|
export const clientEnv = parsed.data;
|
|
|
|
/** @type {"bsk"} */
|
|
export const APP_SLUG = "bsk";
|
|
/** @type {"bsk"} */
|
|
export const SUPABASE_SCHEMA = "bsk";
|