-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvConfig.ts
27 lines (23 loc) · 853 Bytes
/
envConfig.ts
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
import { z } from "zod";
const envSchema = z.object({
NODE_ENV: z
.enum(["development", "staging", "production"])
.default("development"),
DATABASE_URL: z.string().url().nonempty(),
AUTH_NUXT_SECRET: z.string().nonempty().min(16),
AUTH_ORIGIN: z.string().url().default("http://localhost:3000"),
AUTH_AUTH0_CLIENT_ID: z.string().optional(),
AUTH_AUTH0_CLIENT_SECRET: z.string().optional(),
AUTH_AUTH0_ISSUER: z.string().url().optional(),
AUTH_GITHUB_CLIENT_ID: z.string().optional(),
AUTH_GITHUB_CLIENT_SECRET: z.string().optional()
});
const parsedSchema = envSchema.safeParse(process.env);
if (parsedSchema.success === false) {
console.error(
"😔 Your env is invalid!",
parsedSchema.error.flatten().fieldErrors
);
throw new Error("😔 Your env is invalid!");
}
export const envConfig = parsedSchema.data;