File
Blob: src/worker/api/config.ts
| 1 | import type { Hono } from "hono"; |
| 2 | import { ErrorResponse, PublicConfigResponse } from "@/shared/contracts"; |
| 3 | import type { AppBindings } from "@/worker/types"; |
| 4 | |
| 5 | export function registerConfigRoutes(app: Hono<AppBindings>) { |
| 6 | app.get("/api/public/config", async (c) => { |
| 7 | const siteKey = c.env.TURNSTILE_SITE_KEY?.trim(); |
| 8 | |
| 9 | if (!siteKey) { |
| 10 | return c.json( |
| 11 | ErrorResponse.create({ |
| 12 | error: "Human verification is temporarily unavailable.", |
| 13 | }), |
| 14 | 503, |
| 15 | ); |
| 16 | } |
| 17 | |
| 18 | return c.json( |
| 19 | PublicConfigResponse.create({ |
| 20 | turnstileSiteKey: siteKey, |
| 21 | }), |
| 22 | ); |
| 23 | }); |
| 24 | } |