async function fetchStatus() { const el = document.getElementById("status-content"); try { const res = await fetch("/health"); const d = await res.json(); const isOk = d.status === "ok"; const isDegraded = d.status === "degraded"; const dotClass = isOk ? "ok" : isDegraded ? "degraded" : "error"; const label = isOk ? "All Systems Operational" : isDegraded ? "Degraded Performance" : "Service Disruption"; const now = new Date().toLocaleTimeString(); el.innerHTML = "
" + "
" + label + "
" + "
Version " + d.version + " · Last checked " + now + " · Auto-refreshes every 30s
" + "
" + "
" + "
" + "

🗄️ Database

" + "
Status" + (d.database && d.database.status === "ok" ? "Connected" : "Error") + "
" + "
Engine" + (d.database ? d.database.version : "Unknown") + "
" + "
" + "
" + "

🖨️ PDF Engine

" + "
Status 0 ? "ok" : "warn") + "\">" + (d.pool && d.pool.available > 0 ? "Ready" : "Busy") + "
" + "
Available" + (d.pool ? d.pool.available : 0) + " / " + (d.pool ? d.pool.size : 0) + "
" + "
Queue 0 ? "warn" : "ok") + "\">" + (d.pool ? d.pool.queueDepth : 0) + " waiting
" + "
PDFs Generated" + (d.pool ? d.pool.pdfCount.toLocaleString() : "0") + "
" + "
Uptime" + formatUptime(d.pool ? d.pool.uptimeSeconds : 0) + "
" + "
" + "
" + "
Raw JSON endpoint →
"; } catch (e) { el.innerHTML = "
Unable to reach API
The service may be temporarily unavailable. Please try again shortly.
"; } } function formatUptime(s) { if (!s && s !== 0) return "Unknown"; if (s < 60) return s + "s"; if (s < 3600) return Math.floor(s/60) + "m " + (s%60) + "s"; var h = Math.floor(s/3600); var m = Math.floor((s%3600)/60); return h + "h " + m + "m"; } fetchStatus(); setInterval(fetchStatus, 30000);