Skip to content

feat: enhance health check endpoint to verify all upstream dependencies #44

Description

@charannyk06

Priority: P3 — Low

Problem

chainreview-api/src/routes/health.ts exists but likely returns a minimal response (e.g., { status: 'ok' }). A meaningful health check should verify connectivity to all upstream dependencies.

Solution

Enhance the health endpoint to check:

GET /health

Response:
{
  "status": "healthy" | "degraded" | "unhealthy",
  "version": "1.2.3",
  "checks": {
    "database": { "status": "healthy", "latency_ms": 12 },
    "supabase": { "status": "healthy", "latency_ms": 45 },
    "anthropic": { "status": "healthy", "latency_ms": 120 },
    "stripe": { "status": "healthy", "latency_ms": 89 }
  },
  "timestamp": "2026-03-05T10:00:00Z"
}

Implementation

  • Database: Run a simple SELECT 1 query
  • Supabase: Check auth service liveness
  • Anthropic: Optional lightweight check (or just verify key format to avoid unnecessary API calls)
  • Stripe: Optional check against Stripe's status API

Behavior

  • Overall status = "degraded" if any non-critical check fails
  • Overall status = "unhealthy" if critical checks (database) fail
  • Respond with 200 for "healthy"/"degraded", 503 for "unhealthy"
  • Cache responses for 10 seconds to prevent hammering upstream services

Use cases

  • Cloudflare Workers health checks
  • Uptime monitoring (UptimeRobot, Better Stack)
  • Kubernetes liveness/readiness probes (if self-hosted)

Acceptance Criteria

  • /health returns individual dependency check results
  • Returns 503 when critical dependencies are down
  • Response cached for 10 seconds
  • Version included in response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions