Files
intelligence-terminal/apis/utils/env.mjs
calesthio ef2c6470fb Initial release — Crucix Intelligence Engine v2.0.0
26-source OSINT intelligence engine with live Jarvis dashboard,
auto-refresh via SSE, optional LLM layer (4 providers), delta/memory
system, and Telegram breaking news alerts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 23:45:46 -07:00

33 lines
1002 B
JavaScript

// Load .env file for API keys
// Searches: project root .env first, then apis/.env as fallback
import { readFileSync } from 'fs';
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const paths = [
resolve(__dirname, '..', '..', '.env'), // project root
resolve(__dirname, '..', '.env'), // apis/.env (legacy)
];
function loadEnv(filePath) {
try {
const content = readFileSync(filePath, 'utf-8');
let loaded = 0;
for (const line of content.split('\n')) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith('#')) continue;
const eq = trimmed.indexOf('=');
if (eq === -1) continue;
const key = trimmed.slice(0, eq).trim();
const val = trimmed.slice(eq + 1).trim();
if (!process.env[key]) { process.env[key] = val; loaded++; }
}
return loaded;
} catch { return -1; }
}
for (const p of paths) {
if (loadEnv(p) >= 0) break;
}