Session 20: Provider intelligence — quota tracker, gateway with fallback cascade, admin quota dashboard (1476 tests)

This commit is contained in:
Kev
2026-06-12 00:54:39 -04:00
parent 56392ec8f4
commit 9b10bb4138
17 changed files with 1422 additions and 15 deletions
+20
View File
@@ -17,11 +17,31 @@
const express = require('express');
const { requireInternalAuth } = require('../middleware/internalAuth');
const tank01Prefetch = require('../../scripts/tank01-prefetch');
const quotaTracker = require('../services/quotaTracker');
const router = express.Router();
router.use(requireInternalAuth({ loopbackOnly: false }));
/**
* GET /api/internal/quota (Session 20)
*
* Snapshot of every configured provider's current quota counter.
* Consumed by the admin dashboard's "Provider Quotas" tile. Cached
* for 5s so a refresh-button mash doesn't flood Redis.
*/
router.get('/quota', async (req, res) => {
try {
const providers = await quotaTracker.getAllQuotaStatuses();
res.set('Cache-Control', 'private, max-age=5');
return res.json({ ok: true, providers });
} catch (err) {
const message = err && err.message ? err.message : String(err);
console.error('[internal/quota] failed:', message);
return res.status(500).json({ ok: false, error: message });
}
});
/**
* POST /api/internal/prefetch/tank01
*