Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 1x 1x 2x 2x 2x 2x 2x 1x 1x | // Public cost-calculator config endpoint (API-key protected).
// Serves the admin-managed pricing config to the Astro marketplace. Cached
// briefly (KV) so admin edits land fast; the admin PUT also purges this.
import { Hono } from "hono";
import { CACHE_KEYS, CACHE_TTL } from "../../lib/cache";
import { handleError, success } from "../../lib/response";
import type { ContextVariables } from "../../middleware";
type Env = {
Bindings: CloudflareBindings;
Variables: ContextVariables;
};
const calculatorConfig = new Hono<Env>();
// GET /api/marketplace/calculator-config — current pricing config
calculatorConfig.get("/", async (c) => {
try {
const services = c.get("services");
const cache = c.get("cache");
const data = await cache.getOrSet(
CACHE_KEYS.CALCULATOR_CONFIG,
() => services.calculatorConfig.getConfig(),
{
l1Ttl: CACHE_TTL.CALCULATOR_CONFIG_L1,
l2Ttl: CACHE_TTL.CALCULATOR_CONFIG_L2,
},
);
return success(c, data);
} catch (err) {
return handleError(c, err);
}
});
export default calculatorConfig;
|