Files
recap-relay/server/routes/policy.js
T
2026-05-11 22:02:38 -05:00

29 lines
1.0 KiB
JavaScript

// GET /relay/policy — public, no auth. Returns the relay's current
// tier-quota config so Recap installs can show dynamic copy (e.g. the
// activation screen's "N relay credits" line stays in sync when the
// operator tunes the Core lifetime cap via the Adjust Tier Quotas
// StartOS action, with no Recap update required).
//
// Read-only, safe to expose publicly — the response is the same
// information the relay enforces against every request anyway.
import express from "express";
import { getTierQuotas } from "../config.js";
export function policyRouter() {
const router = express.Router();
router.get("/policy", async (_req, res) => {
const tiers = await getTierQuotas();
res.json({
tiers,
// Convenience field for Recap clients that just want "N credits
// for a fresh Core install" without re-deriving from tiers.core.
core_total_credits: tiers.core?.lifetime ?? null,
core_gemini_credits: tiers.core?.geminiCapLifetime ?? null,
});
});
return router;
}