Commit e9947e1
feat(template): replace static /health with dependency-checking handler
Replaces the inline app.get('/health', ...) in both Workers and Node
templates with a mounted routes/health.ts handler. The new handler:
- Pings the database via pingDatabase() with a configurable timeout
(HEALTH_DB_TIMEOUT_MS, default 2000 ms)
- Reports overall status as 'healthy' / 'unhealthy' and returns 503
when any dependency is disconnected
- Includes version (from APP_VERSION env), uptime (seconds since module
load — isolate uptime on Workers, process uptime on Node), timestamp,
requestId, and a checks.database field
- Never throws to the caller: any internal error is caught and reported
as 'disconnected' + 503, so load balancers never see a 5xx that wasn't
caused by an actual dependency outage
Workers Bindings now declare APP_VERSION and HEALTH_DB_TIMEOUT_MS so the
template type-checks against wrangler.toml [vars] entries (added next).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 83a1cea commit e9947e1
1 file changed
Lines changed: 76 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments