mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-12 04:27:00 +00:00
Cache health responses server-side
This commit is contained in:
@@ -9,6 +9,17 @@ export function checkCooldown(cooldowns, key, windowMs, now = Date.now()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
export function getCachedPayload(cache, key, ttlMs, buildPayload, now = Date.now()) {
|
||||
const cached = cache.get(key);
|
||||
if (cached && now - cached.createdAt < ttlMs) {
|
||||
return cached.payload;
|
||||
}
|
||||
|
||||
const payload = buildPayload();
|
||||
cache.set(key, { createdAt: now, payload });
|
||||
return payload;
|
||||
}
|
||||
|
||||
export function isAdminMetricsAuthorized(authHeader, adminToken) {
|
||||
if (!adminToken || typeof adminToken !== 'string') return false;
|
||||
if (!authHeader || typeof authHeader !== 'string') return false;
|
||||
|
||||
Reference in New Issue
Block a user