From 5457fb597028df8b3074d151cae8006754d28e37 Mon Sep 17 00:00:00 2001 From: Space-Banane Date: Sun, 22 Feb 2026 14:59:19 +0100 Subject: [PATCH] add health check endpoint and update webserver routes --- docker-compose.yml | 7 ++++++- src/web/health.ts | 7 +++++++ src/webserver.ts | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/web/health.ts diff --git a/docker-compose.yml b/docker-compose.yml index a374b91..9d543b5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,4 +9,9 @@ services: - .:/app ports: - "$PORT:$PORT" - command: sh -c "npm i -g pnpm && pnpm install && pnpm dev" \ No newline at end of file + command: sh -c "npm i -g pnpm && pnpm install && pnpm dev" + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:$PORT/health"] + interval: 30s + timeout: 10s + retries: 1 \ No newline at end of file diff --git a/src/web/health.ts b/src/web/health.ts new file mode 100644 index 0000000..26f1b19 --- /dev/null +++ b/src/web/health.ts @@ -0,0 +1,7 @@ +import { Express } from 'express'; + +export default function healthRoute(app: Express) { + app.get('/health', (req, res) => { + res.status(200).send('ok'); + }); +} diff --git a/src/webserver.ts b/src/webserver.ts index 1e86c04..e663c26 100644 --- a/src/webserver.ts +++ b/src/webserver.ts @@ -26,7 +26,7 @@ export default async function webserver() { }); const IgnoredPaths = ['/favicon.ico', '/robots.txt', "/", "/hello"]; - const KnownPaths = ["/git-commit", "/"]; + const KnownPaths = ["/git-commit", "/", "/health"]; // log all incoming requests app.use((req, res, next) => {