Spaces:
Runtime error
Runtime error
File size: 2,422 Bytes
fb38ec5 | 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | import { z } from "zod";
import { config } from "dotenv";
config();
const envSchema = z.object({
NODE_ENV: z
.enum(["test", "development", "staging", "production", "preview"])
.default("development"),
HOST: z.string().optional().default("0.0.0.0"),
DOMAIN: z.string().optional(),
PORT: z.string().optional().default("3000"),
USE_SSL: z
.string()
.optional()
.transform((val) => val === "true" || val === "1")
.default("false"),
CDP_REDIRECT_PORT: z.string().optional().default("9222"),
CDP_DOMAIN: z.string().optional(),
PROXY_URL: z.string().optional(),
DEFAULT_HEADERS: z
.string()
.optional()
.transform((val) => (val ? JSON.parse(val) : {}))
.pipe(z.record(z.string()).optional().default({})),
KILL_TIMEOUT: z.string().optional().default("0"),
CHROME_EXECUTABLE_PATH: z.string().optional(),
CHROME_HEADLESS: z
.string()
.optional()
.transform((val) => val === "true" || val === "1")
.default("true"),
DISPLAY: z.string().optional().default(":10"),
ENABLE_CDP_LOGGING: z
.string()
.optional()
.transform((val) => val === "true" || val === "1")
.default("false"),
LOG_CUSTOM_EMIT_EVENTS: z
.string()
.optional()
.transform((val) => val === "true" || val === "1")
.default("false"),
ENABLE_VERBOSE_LOGGING: z
.string()
.optional()
.transform((val) => val === "true" || val === "1")
.default("false"),
DEFAULT_TIMEZONE: z.string().optional(),
TIMEZONE_SERVICE_URL: z.string().optional(),
SKIP_FINGERPRINT_INJECTION: z
.string()
.optional()
.transform((val) => val === "true" || val === "1")
.default("false"),
CHROME_ARGS: z
.string()
.optional()
.transform((val) => (val ? val.split(" ").map((arg) => arg.trim()) : []))
.default(""),
FILTER_CHROME_ARGS: z
.string()
.optional()
.transform((val) => (val ? val.split(" ").map((arg) => arg.trim()) : []))
.default(""),
DEBUG_CHROME_PROCESS: z
.string()
.optional()
.transform((val) => val === "true" || val === "1")
.default("false"),
PROXY_INTERNAL_BYPASS: z.string().optional(),
CHROME_USER_DATA_DIR: z.string().optional(),
LOG_STORAGE_ENABLED: z
.string()
.optional()
.transform((val) => val === "true" || val === "1")
.default("false"),
LOG_STORAGE_PATH: z.string().optional(),
});
export const env = envSchema.parse(process.env);
|