All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 12s
Build & Deploy / 🧪 QA (push) Successful in 2m0s
Build & Deploy / 🏗️ Build (push) Successful in 11m25s
Build & Deploy / 🚀 Deploy (push) Successful in 28s
Build & Deploy / 🧪 Smoke Test (push) Successful in 2m27s
Build & Deploy / ⚡ Lighthouse (push) Successful in 5m39s
Build & Deploy / 🔔 Notify (push) Successful in 1s
68 lines
2.0 KiB
TypeScript
68 lines
2.0 KiB
TypeScript
import { z } from 'zod';
|
|
import { validateMintelEnv, mintelEnvSchema, withMintelRefinements } from '@mintel/next-utils';
|
|
|
|
/**
|
|
* Robust boolean preprocessor for environment variables.
|
|
* Handles strings 'true'/'false' and actual booleans.
|
|
*/
|
|
const booleanSchema = z.preprocess((val) => {
|
|
if (typeof val === 'string') {
|
|
if (val.toLowerCase() === 'true') return true;
|
|
if (val.toLowerCase() === 'false') return false;
|
|
}
|
|
return val;
|
|
}, z.boolean());
|
|
|
|
/**
|
|
* Environment variable schema.
|
|
* Extends the default Mintel environment schema.
|
|
*/
|
|
const envExtension = {
|
|
// Project specific overrides or additions
|
|
AUTH_COOKIE_NAME: z.string().default('klz_gatekeeper_session'),
|
|
|
|
// Gatekeeper specifics not in base
|
|
GATEKEEPER_URL: z.string().url().default('http://gatekeeper:3000'),
|
|
GATEKEEPER_BYPASS_ENABLED: booleanSchema.default(false),
|
|
NEXT_PUBLIC_FEEDBACK_ENABLED: booleanSchema.default(false),
|
|
NEXT_PUBLIC_RECORD_MODE_ENABLED: booleanSchema.default(false),
|
|
|
|
INFRA_DIRECTUS_URL: z.string().url().optional(),
|
|
INFRA_DIRECTUS_TOKEN: z.string().optional(),
|
|
|
|
// Analytics
|
|
NEXT_PUBLIC_UMAMI_WEBSITE_ID: z.string().optional(),
|
|
UMAMI_API_ENDPOINT: z.string().optional(),
|
|
|
|
// Mail Configuration
|
|
MAIL_HOST: z.string().optional(),
|
|
MAIL_PORT: z.coerce.number().optional(),
|
|
MAIL_USERNAME: z.string().optional(),
|
|
MAIL_PASSWORD: z.string().optional(),
|
|
MAIL_FROM: z.string().optional(),
|
|
MAIL_RECIPIENTS: z.string().optional(),
|
|
|
|
// Directus Authentication
|
|
DIRECTUS_URL: z.string().url().optional(),
|
|
DIRECTUS_ADMIN_EMAIL: z.string().email().optional(),
|
|
DIRECTUS_ADMIN_PASSWORD: z.string().optional(),
|
|
DIRECTUS_API_TOKEN: z.string().optional(),
|
|
};
|
|
|
|
/**
|
|
* Full schema including Mintel base and refinements
|
|
*/
|
|
export const envSchema = withMintelRefinements(z.object(mintelEnvSchema).extend(envExtension));
|
|
|
|
/**
|
|
* Validated environment object.
|
|
*/
|
|
export const env = validateMintelEnv(envExtension);
|
|
|
|
/**
|
|
* For legacy compatibility with existing code.
|
|
*/
|
|
export function getRawEnv() {
|
|
return env;
|
|
}
|