Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.5 kB ยท 46 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import { Hono } from "hono";
import openapiV1Json from "../../static/openapi-v1.json" with { type: "json" };// Generated alongside openapi.json; embedded rather than read from disk because// `deno bundle` flattens src/ and a runtime path would resolve from the bundle.import openapiYaml from "../../static/openapi-yaml";import openapiJson from "../../static/openapi.json" with { type: "json" };
// Serialized once: the documents are ~320 KB and never change at runtime.const openapiJsonBody = JSON.stringify(openapiJson);const openapiV1JsonBody = JSON.stringify(openapiV1Json);
// The specs are public and unauthenticated; an agent fetching one from a// browser needs the CORS header to read the body at all.const specHeaders = { "Access-Control-Allow-Origin": "*", "Cache-Control": "public, max-age=3600",};
/** * The machine-readable API descriptions. `openapi.json` is the path agents and * OpenAPI tooling probe by convention; `openapi.yaml` is the generated source * both are rendered from (see `scripts/build-openapi-json.ts`). */export const openapiRoute = new Hono({ strict: false });
openapiRoute.get("/openapi.yaml", (c) => c.text(openapiYaml, 200, { "Content-Type": "application/yaml", ...specHeaders, }),);
openapiRoute.get("/openapi.json", (c) => c.text(openapiJsonBody, 200, { "Content-Type": "application/json", ...specHeaders, }),);
openapiRoute.get("/openapi-v1.json", (c) => c.text(openapiV1JsonBody, 200, { "Content-Type": "application/json", ...specHeaders, }),);