From 282b7972064eff58a247ee53cee03250d6a42274 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Tue, 17 Mar 2026 02:21:24 +0100 Subject: [PATCH] feat: add /health endpoint and Docker healthcheck --- docker-compose.yml | 6 ++++++ server.ts | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index eaabfc6..6ed97b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,6 +14,12 @@ services: - "8080" volumes: - ${DATA_VOLUME:-data}:/data + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/health"] + interval: 10m + timeout: 5s + retries: 3 + start_period: 15s volumes: data: diff --git a/server.ts b/server.ts index 5603d6f..856801c 100644 --- a/server.ts +++ b/server.ts @@ -16,6 +16,10 @@ router.get("/", (ctx) => { ctx.response.body = "Hello world"; }); +router.get("/health", (ctx) => { + ctx.response.body = { status: "ok" }; +}); + router.get("/notes", (ctx) => { const cursor = ctx.request.url.searchParams.get("cursor") ?? undefined; const limit = Number(ctx.request.url.searchParams.get("limit")) || PAGINATION;