import { jsonResponse } from "../../lib/http";
import { cleanText } from "../../lib/text";

export function handleConfigGet(env: Env): Response {
  const cwdApiBase =
    cleanText(env.CWD_API_BASE) || "https://cwd.api.smyhub.com";
  const cwdSiteId = cleanText(env.CWD_SITE_ID) || "";
  return jsonResponse({
    ok: true,
    config: {
      siteTitle: cleanText(env.SITE_TITLE) || "萌芽小窝",
      siteTitleEn: cleanText(env.SITE_TITLE_EN) || "SproutBlog",
      cwdApiBase,
      cwdSiteId: cwdSiteId || undefined
    }
  });
}
