refactor: finalize type-safe env and config using @mintel/next-utils 1.7.8

This commit is contained in:
2026-02-11 00:39:59 +01:00
parent c5c7f2e38d
commit b2bff6109d
2 changed files with 5 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
* Centralized configuration management for the application.
* This file provides a type-safe way to access environment variables.
*/
import { envSchema, getRawEnv } from './env';
import { env, getRawEnv } from './env';
let memoizedConfig: ReturnType<typeof createConfig> | undefined;
@@ -11,7 +11,7 @@ let memoizedConfig: ReturnType<typeof createConfig> | undefined;
* Throws if validation fails.
*/
function createConfig() {
const env = envSchema.parse(getRawEnv()) as any;
const env = getRawEnv();
const target = env.NEXT_PUBLIC_TARGET || env.TARGET;

View File

@@ -10,9 +10,7 @@ import { validateMintelEnv, mintelEnvSchema } from '@mintel/next-utils';
* - Logging
* - Analytics
*/
export const envSchema = z.object({
...mintelEnvSchema,
const envExtension = {
// Project specific overrides or additions
AUTH_COOKIE_NAME: z.string().default('klz_gatekeeper_session'),
@@ -29,12 +27,12 @@ export const envSchema = z.object({
INFRA_DIRECTUS_URL: z.string().url().optional(),
INFRA_DIRECTUS_TOKEN: z.string().optional(),
});
};
/**
* Validated environment object.
*/
export const env = validateMintelEnv(envSchema.shape);
export const env = validateMintelEnv(envExtension);
/**
* For legacy compatibility with existing code.