Files
web/env/schema.mjs
2024-02-07 11:58:54 +01:00

47 lines
1.5 KiB
JavaScript

// @ts-check
import { z } from "zod"
/**
* Specify your server-side environment variables schema here.
* This way you can ensure the app isn"t built with invalid env vars.
*/
export const serverSchema = z.object({
CMS_ACCESS_TOKEN: z.string(),
CMS_API_KEY: z.string(),
CMS_ENVIRONMENT: z.enum(["development", "production", "staging", "test"]),
CMS_URL: z.string(),
NODE_ENV: z.enum(["development", "test", "production"]),
PRINT_QUERY: z.boolean().default(false),
})
/**
* You can't destruct `process.env` as a regular object in the Next.js
* middleware, so you have to do it manually here.
* @type {{ [k in keyof z.input<typeof serverSchema>]: string | undefined }}
*/
export const serverEnv = {
CMS_ACCESS_TOKEN: process.env.CMS_ACCESS_TOKEN,
CMS_API_KEY: process.env.CMS_API_KEY,
CMS_ENVIRONMENT: process.env.CMS_ENVIRONMENT,
CMS_URL: process.env.CMS_URL,
NODE_ENV: process.env.NODE_ENV,
PRINT_QUERY: process.env.PRINT_QUERY,
}
/**
* Specify your client-side environment variables schema here.
* This way you can ensure the app isn"t built with invalid env vars.
* To expose them to the client, prefix them with `NEXT_PUBLIC_`.
*/
export const clientSchema = z.object({
})
/**
* You can't destruct `process.env` as a regular object, so you have to do
* it manually here. This is because Next.js evaluates this at build time,
* and only used environment variables are included in the build.
* @type {{ [k in keyof z.infer<typeof clientSchema>]: z.infer<typeof clientSchema>[k] | undefined }}
*/
export const clientEnv = {
}