Reorganize repo structure and standards references

This commit is contained in:
david committed 2026-06-29 05:03:42 +02:00
1 parent 3cb93a81be
commit be2054274d
5885 files changed
+2588 -195

No files matched your search

@@ -0,0 +1,89 @@
import { Hono, type Context } from "hono";
import { getApiAppDependencies } from "../app-dependencies.js";
import type { ApiEnv } from "../api-types.js";
import { getApiRuntimeConfig } from "../config.js";
import { createOpenApiDocument } from "../openapi.js";
import { escapeHtml } from "./shared.js";
function apiHealthResponse(c: Context<ApiEnv>) {
return c.json({
status: "ok",
service: "api",
revision: getApiRuntimeConfig().revision,
requestId: c.get("requestId"),
});
}
export function registerSystemRoutes(app: Hono<ApiEnv>) {
app.get("/healthz", apiHealthResponse);
app.get("/v1/health", apiHealthResponse);
app.get("/readyz", async (c) => {
try {
await getApiAppDependencies().checkReadiness();
return c.json({
status: "ready",
service: "api",
revision: getApiRuntimeConfig().revision,
requestId: c.get("requestId"),
});
} catch {
return c.json(
{
status: "not_ready",
service: "api",
requestId: c.get("requestId"),
error: {
code: "dependency_unavailable",
message: "A required dependency is unavailable.",
},
},
503
);
}
});
app.get("/v1/openapi.json", (c) => {
return c.json(createOpenApiDocument(getApiRuntimeConfig()));
});
app.get("/v1/docs", (c) => {
const appName = getApiRuntimeConfig().appName;
return c.html(`<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>API Documentation | ${escapeHtml(appName)}</title>
<meta property="og:title" content="API Documentation | ${escapeHtml(appName)}">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body { margin: 0; background: #0f172a; color: #e2e8f0; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
header { border-bottom: 1px solid #334155; padding: 20px 24px; }
main { padding: 24px; }
a { color: #93c5fd; }
pre { margin: 0; overflow: auto; border: 1px solid #334155; border-radius: 8px; background: #020617; padding: 16px; line-height: 1.5; }
</style>
</head>
<body>
<header>
<h1>API Documentation</h1>
<a href="/v1/openapi.json">OpenAPI JSON</a>
</header>
<main>
<pre id="openapi">Loading /v1/openapi.json...</pre>
</main>
<script>
fetch("/v1/openapi.json")
.then((response) => response.json())
.then((spec) => {
document.getElementById("openapi").textContent = JSON.stringify(spec, null, 2);
})
.catch((error) => {
document.getElementById("openapi").textContent = error.message;
});
</script>
</body>
</html>`);
});
}