-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.mjs
57 lines (56 loc) · 1.7 KB
/
env.mjs
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";
export const env = createEnv({
server: {
ADMINS: z.preprocess(
(value) => (value && JSON.parse(value)) || [],
z.array(z.string()),
),
ANALYZE: z
.enum(["true", "false"])
.optional()
.transform((value) => value === "true"),
CI: z
.string()
.optional()
.transform((value) => !!value && value !== "false" && value !== "0"),
DATABASE_URL: z.string(),
EDGE_CONFIG: z.string().optional(),
NODE_ENV: z
.enum(["development", "production", "test"])
.default("development"),
SUPERTOKENS_API_KEY: z.string(),
SUPERTOKENS_CONNECTION_URI: z.string(),
VERCEL_ENV: z
.enum(["development", "preview", "production"])
.default("development"),
VERCEL_GIT_COMMIT_SHA: z
.string()
.optional()
.transform((sha) => sha || "local"),
VERCEL_URL: z
.string()
.optional()
.transform((url) => {
if (!url) {
return "http://localhost:3000";
}
// Ensure that the URL starts with https:// or http://
return url.match(/^https?:\/\//) ? url : `https://${url}`;
}),
},
client: {},
runtimeEnv: {
ADMINS: process.env.ADMINS,
ANALYZE: process.env.ANALYZE,
CI: process.env.CI,
DATABASE_URL: process.env.DATABASE_URL,
EDGE_CONFIG: process.env.EDGE_CONFIG,
NODE_ENV: process.env.NODE_ENV,
SUPERTOKENS_API_KEY: process.env.SUPERTOKENS_API_KEY,
SUPERTOKENS_CONNECTION_URI: process.env.SUPERTOKENS_CONNECTION_URI,
VERCEL_ENV: process.env.VERCEL_ENV,
VERCEL_GIT_COMMIT_SHA: process.env.VERCEL_GIT_COMMIT_SHA,
VERCEL_URL: process.env.VERCEL_URL,
},
});