- Connect with a licence key (/setup last screen, Site settings -> Licence) - hub-heartbeat job every 15 min: version, health, totals (income as a band) - Licence tokens verified with the Hub's public key; states active / grace (banner for site admins only) / suspended / revoked (read-only) / unlicensed; Hub keys kept out of the generic settings endpoints - /health; "update available" for admins; scripts/install.sh - docs/hub-protocol.md shared with the events-hub repo - Unit tests (hub.test.js); docs The production Hub public key (backend/src/hub/publicKey.js) must be set before this is released. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mt6TCv85T9VKRq3cV7rXq
18 lines
546 B
JavaScript
18 lines
546 B
JavaScript
// Server errors (5xx responses) in the last 24 hours, for the Hub heartbeat. In memory per
|
|
// process: a restart starts again from zero, which is fine for spotting a spike.
|
|
const WINDOW_MS = 24 * 60 * 60 * 1000;
|
|
const MAX_KEPT = 10000;
|
|
let times = [];
|
|
|
|
function recordError(now = Date.now()) {
|
|
times.push(now);
|
|
if (times.length > MAX_KEPT) times = times.slice(-MAX_KEPT);
|
|
}
|
|
|
|
function countLast24h(now = Date.now()) {
|
|
times = times.filter(t => now - t < WINDOW_MS);
|
|
return times.length;
|
|
}
|
|
|
|
module.exports = { recordError, countLast24h };
|