mirror of
https://github.com/Sea-Haven-Industries/seahaven-ap.git
synced 2026-09-30 12:43:19 +00:00
Move liveness to GET /api/health { stage, sha } with a Node 24 image on 8080 so ALB probes and deploy verify do not need auth or a database ping.
28 lines
925 B
TypeScript
28 lines
925 B
TypeScript
import { Hono } from "hono";
|
|
import type { ApiEnv } from "./env.js";
|
|
import type { Db } from "./db/client.js";
|
|
import { createAuthMiddleware, type AppBindings } from "./auth/middleware.js";
|
|
import { createHealthRoutes } from "./routes/health.js";
|
|
import { createMeRoutes } from "./routes/me.js";
|
|
import { errorJson } from "./http.js";
|
|
|
|
export function createApp(env: ApiEnv, handle: Db) {
|
|
const app = new Hono<AppBindings>();
|
|
const auth = createAuthMiddleware(env, handle);
|
|
|
|
const api = new Hono<AppBindings>();
|
|
api.route("/", createHealthRoutes(env, handle));
|
|
api.use("*", auth);
|
|
api.route("/", createMeRoutes());
|
|
app.route("/api", api);
|
|
|
|
app.notFound((c) => errorJson(c, 404, "NOT_FOUND", "Not found."));
|
|
app.onError((error, c) => {
|
|
console.error(error);
|
|
return errorJson(c, 500, "INTERNAL_ERROR", "Internal server error.");
|
|
});
|
|
|
|
return app;
|
|
}
|
|
|
|
export type App = ReturnType<typeof createApp>;
|