Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apis/utils/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions apis/utils/fetch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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)));
Expand Down
2 changes: 1 addition & 1 deletion server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)}║
Expand Down