-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.js
35 lines (34 loc) · 1001 Bytes
/
env.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";
export const env = createEnv({
server: {
NODE_ENV: z.enum(["development", "test", "production"]),
ANALYZE: z
.enum(["true", "false"])
.optional()
.transform((value) => value === "true"),
CI: z
.enum(["true", "false", "0", "1"])
.optional()
.transform((value) => value === "true" || value === "1")
},
client: {
// Client env variables, eg:
// NEXT_PUBLIC_CLIENT_VAR: z.string(),
},
runtimeEnv: {
NODE_ENV: process.env.NODE_ENV,
ANALYZE: process.env.ANALYZE,
CI: process.env.CI
},
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially
* useful for Docker builds.
*/
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
/**
* Makes it so that empty strings are treated as undefined. `SOME_VAR: z.string()` and
* `SOME_VAR=''` will throw an error.
*/
emptyStringAsUndefined: true
});