17 lines
535 B
TypeScript
17 lines
535 B
TypeScript
const required = <K extends keyof typeof RAW_PUBLIC_ENV>(name: K) => {
|
|
const v = RAW_PUBLIC_ENV[name];
|
|
if (!v) throw new Error(`Missing env: ${name}`);
|
|
return v;
|
|
};
|
|
|
|
const RAW_PUBLIC_ENV = {
|
|
NEXT_PUBLIC_ENV: process.env.NEXT_PUBLIC_ENV,
|
|
NEXT_PUBLIC_API_BASE: process.env.NEXT_PUBLIC_API_BASE,
|
|
NEXT_PUBLIC_STORE_KEY: process.env.NEXT_PUBLIC_STORE_KEY,
|
|
} as const;
|
|
|
|
export const clientEnv = {
|
|
ENV: required("NEXT_PUBLIC_ENV"),
|
|
API_BASE: required("NEXT_PUBLIC_API_BASE"),
|
|
STORE_KEY: required("NEXT_PUBLIC_STORE_KEY"),
|
|
}; |