v0.2.4 max-monthly union + /relay/policy

This commit is contained in:
local
2026-05-11 22:02:38 -05:00
parent 6797aae404
commit e612e8b8e8
6 changed files with 113 additions and 10 deletions
+2
View File
@@ -22,6 +22,7 @@ import { transcribeRouter } from "./routes/transcribe.js";
import { analyzeRouter } from "./routes/analyze.js";
import { healthRouter } from "./routes/health.js";
import { balanceRouter } from "./routes/balance.js";
import { policyRouter } from "./routes/policy.js";
import { adminRouter } from "./routes/admin.js";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -47,6 +48,7 @@ setupAdminAuthRoutes(app);
// authenticates per-call via headers (X-Recap-Install-Id required,
// Authorization optional).
app.use("/relay", healthRouter());
app.use("/relay", policyRouter());
app.use("/relay", balanceRouter());
app.use("/relay", transcribeRouter());
app.use("/relay", analyzeRouter());
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "recap-relay-server",
"version": "0.2.3",
"version": "0.2.4",
"type": "module",
"private": true,
"dependencies": {
+28
View File
@@ -0,0 +1,28 @@
// 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;
}