diff --git a/apis/utils/env.mjs b/apis/utils/env.mjs index 0b60ee8..1cc7dd9 100644 --- a/apis/utils/env.mjs +++ b/apis/utils/env.mjs @@ -20,7 +20,11 @@ function loadEnv(filePath) { const eq = trimmed.indexOf('='); if (eq === -1) continue; const key = trimmed.slice(0, eq).trim(); - const val = trimmed.slice(eq + 1).trim(); + let val = trimmed.slice(eq + 1).trim(); + // Strip surrounding quotes (single or double) — matches dotenv behavior + if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) { + val = val.slice(1, -1); + } if (!process.env[key]) { process.env[key] = val; loaded++; } } return loaded; diff --git a/apis/utils/fetch.mjs b/apis/utils/fetch.mjs index 312859d..515bf9f 100644 --- a/apis/utils/fetch.mjs +++ b/apis/utils/fetch.mjs @@ -4,9 +4,9 @@ export async function safeFetch(url, opts = {}) { const { timeout = 15000, retries = 1, headers = {} } = opts; let lastError; for (let i = 0; i <= retries; i++) { + const controller = new AbortController(); + const timer = setTimeout(() => controller.abort(), timeout); try { - const controller = new AbortController(); - const timer = setTimeout(() => controller.abort(), timeout); const res = await fetch(url, { signal: controller.signal, headers: { 'User-Agent': 'Crucix/1.0', ...headers }, @@ -19,6 +19,7 @@ export async function safeFetch(url, opts = {}) { const text = await res.text(); try { return JSON.parse(text); } catch { return { rawText: text.slice(0, 500) }; } } catch (e) { + clearTimeout(timer); lastError = e; // GDELT needs 5s between requests, others are fine with shorter delays if (i < retries) await new Promise(r => setTimeout(r, 2000 * (i + 1))); diff --git a/server.mjs b/server.mjs index 157fbc8..8a8978d 100644 --- a/server.mjs +++ b/server.mjs @@ -400,7 +400,7 @@ async function start() { console.log(` ╔══════════════════════════════════════════════╗ ║ CRUCIX INTELLIGENCE ENGINE ║ - ║ Local Palantir · 26 Sources ║ + ║ Local Palantir · 29 Sources ║ ╠══════════════════════════════════════════════╣ ║ Dashboard: http://localhost:${port}${' '.repeat(14 - String(port).length)}║ ║ Health: http://localhost:${port}/api/health${' '.repeat(4 - String(port).length)}║