Files
Void-Homelab/lib/api/routes/cluster.js
root b0b23ba05d feat(infra): commit live infra-audit/cluster work to reconcile git with prod
This work (network_hosts inventory + infra_audit MCP tool, /api/cluster +
Sacred Valley cluster card, topbar cluster-health pill + SW self-heal) was
built in an earlier session and DEPLOYED to CT 311 as alpha.24–26, but was
never committed to git — prod was running code absent from the repo. Commits
it as-is (already prod-validated) so git matches the live state, and restores
its alpha.24/25/26 CHANGELOG entries. Files are disjoint from the fold-in
work; both now ship together under alpha.27.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-08 15:20:38 +10:00

18 lines
605 B
JavaScript

import { Router } from 'express';
import { asyncWrap } from '../errors.js';
import { clusterHealth } from '../../proxmox/cluster.js';
// Read-only cluster health for the Sacred Valley card. Cached briefly so multiple
// polling clients coalesce into one PVE call. Owner or any authed agent.
export const router = Router();
let cache = { at: 0, data: null };
const TTL = 10_000;
router.get('/', asyncWrap(async (_req, res) => {
if (cache.data && Date.now() - cache.at < TTL) return res.json(cache.data);
const data = await clusterHealth();
cache = { at: Date.now(), data };
res.json(data);
}));