Skip to content

Add a /api/health Endpoint for System Monitoring #41

@yash-pouranik

Description

@yash-pouranik

🌟 [GFI] Add a /api/health Endpoint for System Monitoring

Description

To ensure our backend infrastructure (Node.js API, MongoDB, and Redis) is running smoothly, we need a dedicated Health Check endpoint. This is a standard practice in backend engineering, allowing uptime monitoring services (like UptimeRobot or Datadog) to verify that our system is healthy and connected to its dependencies.

🎯 What needs to be done:

  1. Navigate to the backend/routes/ directory.
  2. Create a new file (or add to an existing general route file) to handle a GET /api/health request.
  3. In the controller logic, perform quick connectivity checks:
    • Check if the Mongoose connection to MongoDB is ready (mongoose.connection.readyState === 1).
    • Check if the Redis client is connected and responsive.
  4. Return a JSON response detailing the status of the API and its dependencies.

📝 Expected JSON Response Format:

{
  "status": "ok", // or "error" if dependencies fail
  "timestamp": "2026-03-08T12:00:00.000Z",
  "dependencies": {
    "mongodb": "connected", // or "disconnected"
    "redis": "connected"    // or "disconnected"
  }
}

💡 How to Contribute:

  • Comment on this issue to get it assigned to you.
  • Fork the repository and create a new branch (e.g., feat/health-endpoint).
  • Implement the logic and test it locally using Postman, cURL, or your browser.
  • Submit a Pull Request (PR) and mention this issue (e.g., Fixes #ISSUE_NUMBER).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions