Skip to content

Add health check endpoint with dependency status #54

@PAMulligan

Description

@PAMulligan

Description

Enhance the generated `/health` endpoint to include dependency status checks (database connectivity, external services). The current template returns a simple `{ status: "ok" }` with no actual health verification.

Why

A health endpoint that always returns "ok" is useless for monitoring. Production deployments (Docker, Kubernetes, Cloudflare) use health checks to determine if an instance should receive traffic. Checking database connectivity catches the most common failure mode.

Current State

```typescript
app.get('/health', (c) => {
return c.json({ status: 'ok', timestamp: new Date().toISOString() });
});
```

The `pipeline.config.json` already specifies:
```json
"healthCheck": {
"path": "/health",
"includeDbStatus": true,
"includeVersion": true
}
```

But the template doesn't implement these features.

Acceptance Criteria

  • Update the health endpoint template in `setup-project.sh` to:
    • Check database connectivity (simple query like `SELECT 1`)
    • Return `status: "healthy"` or `status: "unhealthy"`
    • Include database status (`"connected"` / `"disconnected"`)
    • Include API version from `package.json`
    • Include uptime in seconds
    • Return HTTP 503 if any dependency is unhealthy
  • Apply to both Cloudflare Workers and Node.js templates
  • Update the existing health test to cover the new response shape
  • CI passes

Example Response

```json
{
"status": "healthy",
"version": "0.0.1",
"uptime": 3600,
"timestamp": "2026-04-08T12:00:00Z",
"checks": {
"database": "connected"
}
}
```

Metadata

Metadata

Assignees

No fields configured for Feature.

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions