Skip to content

docs: document the /healthcheck endpoint - #493

Merged
abroa01 merged 1 commit into
developmentfrom
docs/healthcheck-api
Sep 15, 2026
Merged

abroa01 merged 1 commit into
developmentfrom
docs/healthcheck-api

Conversation

@abroa01

@abroa01 abroa01 commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds documentation for the /healthcheck endpoint, which was implemented but only briefly described in the README (status codes, no response schema).

Changes

  • New: docs/API_HEALTHCHECK.md — full endpoint reference following the style of the existing docs/API_INVITES.md:
    • Supported methods (GET, HEAD), exact-path matching, query strings ignored
    • Authentication: none, with a note on what the endpoint does and does not expose
    • Status codes: 200 healthy, 503 for not-writable and for unreachable
    • Response field table and example bodies for all three outcomes
    • HEAD behavior (empty body per RFC 9110 §9.3.2)
    • curl examples for body, status-code-only, and script-failure probes
    • Implementation notes: runs on the app database so no elevated Mongo privileges are needed; hello with legacy isMaster fallback for MongoDB < 4.4
    • Multi-instance guidance: probe each instance, not the load-balancer address
  • Updated: README.md — links the new doc from the API surface section and from the Operations → Healthcheck section.

Notes

Documentation only. No source or test changes. Content was derived from server/healthcheck.js, server/main.js, and tests/healthcheck.js.

Based on development.

Add docs/API_HEALTHCHECK.md covering the endpoint contract: supported methods, exact-path matching, unauthenticated access, the 200/503 status codes, the JSON response fields, and example bodies for healthy, non-writable, and unreachable MongoDB. Include HEAD behavior, curl examples, the hello/isMaster fallback, and multi-instance probing guidance. Link the new doc from the README API surface table and the operations Healthcheck section.
Copilot AI lite review requested due to automatic review settings September 15, 2026 14:11
@abroa01
abroa01 merged commit a65d9a6 into development Sep 15, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Documents the existing /healthcheck endpoint and links the reference from the README.

Changes:

  • Added comprehensive healthcheck endpoint documentation.
  • Updated README API and operations links.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
README.md Links to the healthcheck documentation.
docs/API_HEALTHCHECK.md Documents endpoint behavior, responses, probes, and deployment guidance.
Suppressed comments (2)

docs/API_HEALTHCHECK.md:45

  • This guarantee needs to be scoped to requests handled by this endpoint. Unsupported methods and sub-paths call next() in server/main.js, so they can receive the normal application's status codes and content types rather than the 200/503 JSON contract described here.
There are no other status codes. Every response carries the
`Content-Type: application/json` header, including `HEAD` responses.

docs/API_HEALTHCHECK.md:8

  • Because this check returns 503 for MongoDB outages and read-only nodes, using it as a liveness probe can cause an orchestrator to restart otherwise healthy application containers during a database incident. Please describe it as a readiness/load-balancer probe or explicitly warn against using it for process liveness.
The `/healthcheck` endpoint reports whether the application can reach MongoDB
and whether the connected node accepts writes. It is intended for load-balancer
health probes, container orchestrator liveness/readiness checks, and uptime
monitoring.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/API_HEALTHCHECK.md
Comment on lines +22 to +24
The path must match exactly. Sub-paths such as `/healthcheck/db` are not handled
and fall through to the normal application routes. Query strings are ignored, so
`/healthcheck?probe=lb` behaves identically to `/healthcheck`.
Comment thread docs/API_HEALTHCHECK.md
Comment on lines +32 to +34
It exposes no user data, no configuration values, and no database contents. The
only information returned is MongoDB reachability, writability, and a driver
error message when a check fails.
Comment thread docs/API_HEALTHCHECK.md
Comment on lines +147 to +150
- Writability is detected with the `hello` command, which requires MongoDB 4.4
or newer. On older servers the check falls back to the legacy `isMaster`
command so that a reachable node is not misreported as disconnected. The
writable flag is read from `isWritablePrimary`, falling back to `ismaster`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants