refactor: standardize env and analytics using enhanced @mintel/next-utils
Some checks failed
Some checks failed
This commit is contained in:
34
apps/web/lib/env.ts
Normal file
34
apps/web/lib/env.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { z } from "zod";
|
||||
import { validateMintelEnv, mintelEnvSchema } from "@mintel/next-utils";
|
||||
|
||||
/**
|
||||
* Environment variable schema for the main website.
|
||||
* Extends the default Mintel environment schema.
|
||||
*/
|
||||
export const envSchema = z.object({
|
||||
...mintelEnvSchema,
|
||||
|
||||
// Project specific overrides or additions
|
||||
AUTH_COOKIE_NAME: z.string().default("mintel_gatekeeper_session"),
|
||||
|
||||
// Analytics provider toggle
|
||||
NEXT_PUBLIC_ANALYTICS_PROVIDER: z
|
||||
.enum(["plausible", "umami"])
|
||||
.default("plausible"),
|
||||
|
||||
// Plausible specifics (to be standardized later if needed)
|
||||
NEXT_PUBLIC_PLAUSIBLE_DOMAIN: z.string().default("mintel.me"),
|
||||
NEXT_PUBLIC_PLAUSIBLE_SCRIPT_URL: z.string().url().optional(),
|
||||
});
|
||||
|
||||
/**
|
||||
* Validated environment object.
|
||||
*/
|
||||
export const env = validateMintelEnv(envSchema.shape);
|
||||
|
||||
/**
|
||||
* For legacy compatibility with existing code.
|
||||
*/
|
||||
export function getRawEnv() {
|
||||
return env;
|
||||
}
|
||||
Reference in New Issue
Block a user