From 9e52814ab3f8029a414fe6304e04fac322e80085 Mon Sep 17 00:00:00 2001 From: Michael Thiesen Date: Sat, 26 Oct 2024 15:51:18 -0700 Subject: [PATCH] Removed dotenv dependency to streamline configuration handling --- package.json | 1 - pnpm-lock.yaml | 3 --- src/utils/config.ts | 15 ++++++--------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index e0ca980..3874c0f 100755 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "dependencies": { "@micthiesen/mitools": "^1.1.1", "date-fns": "^4.1.0", - "dotenv": "^16.4.5", "html-entities": "^2.5.2", "node-cron": "^3.0.3", "p-queue": "^8.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0afec9b..36de9bf 100755 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,9 +14,6 @@ importers: date-fns: specifier: ^4.1.0 version: 4.1.0 - dotenv: - specifier: ^16.4.5 - version: 16.4.5 html-entities: specifier: ^2.5.2 version: 2.5.2 diff --git a/src/utils/config.ts b/src/utils/config.ts index 532e52e..ce41d78 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -1,13 +1,8 @@ import { baseConfigSchema } from "@micthiesen/mitools"; -import dotenv from "dotenv"; import { z } from "zod"; -// Load environment variables from .env file if it exists -dotenv.config(); - -// Define a Zod schema for the environment variables const stringBoolean = (value: string): boolean => value.toLowerCase() === "true"; -const envSchema = baseConfigSchema.extend({ +const configSchema = baseConfigSchema.extend({ YT_CHANNEL_NAMES: z .string() .optional() @@ -15,15 +10,17 @@ const envSchema = baseConfigSchema.extend({ OFFLINE_NOTIFICATIONS: z.string().optional().default("true").transform(stringBoolean), }); -export type Config = z.infer; +export type Config = z.infer; -const config = envSchema.parse(process.env); +const config = configSchema.parse(process.env); console.log( "Config:", Object.fromEntries( Object.entries(config).map(([key, value]) => [ key, - key.includes("TOKEN") || key.includes("KEY") ? "***" : value, + key.includes("TOKEN") || key.includes("KEY") || key.includes("USER") + ? "***" + : value, ]), ), );