3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Fix .env number validation errors

This commit is contained in:
Dragory 2022-06-26 14:41:31 +03:00
parent 177a66a247
commit 12274a84b2
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -19,19 +19,22 @@ const envType = z.object({
PHISHERMAN_API_KEY: z.string().optional(), PHISHERMAN_API_KEY: z.string().optional(),
API_PORT: z.number().min(1).max(65535), API_PORT: z.preprocess((v) => Number(v), z.number().min(1).max(65535)),
DOCKER_MYSQL_PASSWORD: z.string().optional(), // Included here for the DB_PASSWORD default in development DOCKER_MYSQL_PASSWORD: z.string().optional(), // Included here for the DB_PASSWORD default in development
DB_HOST: z.string().optional().default("mysql"), DB_HOST: z.string().optional().default("mysql"),
DB_PORT: z.number().optional().default(3306), DB_PORT: z
.preprocess((v) => Number(v), z.number())
.optional()
.default(3306),
DB_USER: z.string().optional().default("zeppelin"), DB_USER: z.string().optional().default("zeppelin"),
DB_PASSWORD: z.string().optional(), // Default is set to DOCKER_MYSQL_PASSWORD further below DB_PASSWORD: z.string().optional(), // Default is set to DOCKER_MYSQL_PASSWORD further below
DB_DATABASE: z.string().optional().default("zeppelin"), DB_DATABASE: z.string().optional().default("zeppelin"),
}); });
let toValidate = {}; let toValidate = {};
const envPath = path.join(rootDir, "../.env"); const envPath = path.join(rootDir, ".env");
if (fs.existsSync(envPath)) { if (fs.existsSync(envPath)) {
const buf = fs.readFileSync(envPath); const buf = fs.readFileSync(envPath);
toValidate = dotenv.parse(buf); toValidate = dotenv.parse(buf);