Skip to content

feat: add health check endpoint - #197

Open
Arnish-val wants to merge 2 commits into
pavanvamsi3:mainfrom
Arnish-val:add-health-check-endpoint
Open

feat: add health check endpoint#197
Arnish-val wants to merge 2 commits into
pavanvamsi3:mainfrom
Arnish-val:add-health-check-endpoint

Conversation

@Arnish-val

Copy link
Copy Markdown

Closes #193

Summary

  • Added a lightweight GET /api/health endpoint.
  • Returns HTTP 200 with an ok status and version string.
  • Added endpoint coverage with Vitest.

Testing

  • Verified GET /api/health locally.
  • Ran npm test.
Screenshot 2026-06-23 014754

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

Adds a lightweight liveness/readiness endpoint to the Express backend so deployments behind proxies/CI can probe server availability without hitting data-heavy routes.

Changes:

  • Added GET /api/health returning { status: "ok", version: <string> }.
  • Added a Vitest integration test that starts the app and probes /api/health.
Show a summary per file
File Description
src/server.ts Adds the /api/health route to the Express app.
src/__tests__/server.test.ts Adds an integration test that starts a local server and validates the health response.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Low

Comment thread src/server.ts Outdated
Comment thread src/__tests__/server.test.ts
Comment thread src/__tests__/server.test.ts
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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.

Review details

Suppressed comments (3)

src/server.ts:65

  • The new /api/health handler is the only route here without the existing try/catch + JSON 500 error pattern used by the other endpoints. For consistency (and to avoid any unexpected unhandled errors), wrap the handler body in try/catch and return a JSON error on failure.
  // API: Health check
  app.get("/api/health", (_req, res) => {
    res.status(200).json({

      status: "ok",
      version: appVersion,

    });
  });

src/server.ts:57

  • These newly added lines contain stray carriage-return characters (mixed CRLF/LF), which can cause noisy diffs and tooling issues. Please normalize line endings in this block to match the rest of the file (LF).
  // Cache version once when the app is created (avoid per-request I/O)

  let appVersion = process.env.npm_package_version;

  if (!appVersion) {

    try {

      appVersion = (require("../package.json") as { version?: string }).version;

src/tests/server.test.ts:44

  • If server.address() is missing/unexpected, the test throws before entering the try/finally and the server is never closed. Move the address validation inside the try block so the server is always closed in finally.
    const address = server.address();

    if (!address || typeof address === "string") {
      throw new Error("Test server did not start correctly");
    }
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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.

Add /api/health endpoint for liveness checks

2 participants