Files
klz-cables.com/lib/env.ts

42 lines
1.2 KiB
TypeScript

import { z } from 'zod';
import { validateMintelEnv, mintelEnvSchema } from '@mintel/next-utils';
/**
* Environment variable schema.
* Extends the default Mintel environment schema.
*/
export const envSchema = z.object({
...mintelEnvSchema,
// Project specific variables
NEXT_PUBLIC_TARGET: z.enum(['development', 'testing', 'staging', 'production']).optional(),
TARGET: z.enum(['development', 'testing', 'staging', 'production']).optional(),
// Directus (Extended from base)
INTERNAL_DIRECTUS_URL: z.string().url().optional(),
INFRA_DIRECTUS_URL: z.string().url().optional(),
INFRA_DIRECTUS_TOKEN: z.string().optional(),
// Gatekeeper
GATEKEEPER_URL: z.string().url().default('http://gatekeeper:3000'),
GATEKEEPER_BYPASS_ENABLED: z.preprocess(
(val) => val === 'true' || val === true,
z.boolean().default(false),
),
NEXT_PUBLIC_FEEDBACK_ENABLED: z.preprocess(
(val) => val === 'true' || val === true,
z.boolean().default(false),
),
});
/**
* Validated environment object.
*/
export const env = validateMintelEnv(envSchema.shape);
/**
* For legacy compatibility with existing code.
*/
export function getRawEnv() {
return env;
}