refactor: Enhance environment configuration and loading mechanism

- Implement flexible environment variable loading strategy
- Add support for environment-specific and local override configuration files
- Create new `loadEnv.ts` module for dynamic environment configuration
- Update configuration loading in multiple config files
- Remove deprecated `.env.development.template`
- Add setup script for environment validation
- Improve WebSocket error handling and client configuration
This commit is contained in:
jango-blockchained
2025-02-06 08:55:23 +01:00
parent e96fa163cd
commit 69e9c7de55
15 changed files with 193 additions and 741 deletions

View File

@@ -1,16 +1,7 @@
import { config } from "dotenv";
import { resolve } from "path";
import { loadEnvironmentVariables } from "./loadEnv";
// Load environment variables based on NODE_ENV
const envFile =
process.env.NODE_ENV === "production"
? ".env"
: process.env.NODE_ENV === "test"
? ".env.test"
: ".env.development";
console.log(`Loading environment from ${envFile}`);
config({ path: resolve(process.cwd(), envFile) });
// Load environment variables from the appropriate files
loadEnvironmentVariables();
// Home Assistant Configuration
export const HASS_CONFIG = {