Skip to content
File

Blob: src/worker/api/config.ts

typescript25 lines
1import type { Hono } from "hono";
2import { ErrorResponse, PublicConfigResponse } from "@/shared/contracts";
3import type { AppBindings } from "@/worker/types";
4 
5export 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}