Skip to content

feat(api): add /api/health endpoint for service and GitHub token status #7806

Description

@adepat06

Is your feature request related to a problem? Please describe.

There's currently no lightweight endpoint to check whether the service and the
shared GITHUB_TOKEN are actually working. Self-hosters and uptime monitors
(UptimeRobot, Kubernetes liveness probes, etc.) have no reliable way to verify
service health without hitting the full /api/streak route — which requires a
valid username and burns a real GraphQL request just to check if the app is up.

Describe the solution you'd like

Add a GET /api/health route that performs a minimal GitHub GraphQL check
(e.g. a lightweight viewer { login } query, or a rate-limit query) and
returns a simple JSON status:

  • 200 { status: "ok", githubApi: "ok" } when the token is valid and reachable
  • 503 { status: "degraded", githubApi: "error", message } when the GitHub
    API call fails or the token is invalid/expired

The endpoint should not require a user query param and should not touch the
contribution-data caching path, so it stays fast and cheap to poll.

Files likely involved:

  • app/api/health/route.ts (new)
  • lib/github.ts

Would also add a basic test covering both the healthy and failure paths.

Describe alternatives you've considered

  • Hitting /api/streak?user= as a proxy health check —
    rejected because it requires a real username, consumes a full GraphQL
    contribution query, and doesn't distinguish "app is down" from "user not found".
  • Relying on Vercel's own deployment status page — doesn't tell you whether the
    GITHUB_TOKEN itself is valid or rate-limited, which is the actual failure mode
    self-hosters care about.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions