Skip to content

[Feature] : Refactor Health Check Route into a Dedicated Controller #102

Description

@jikrana1

Description

📌 Overview

The current health check endpoint is implemented directly inside the main server file. While it works correctly, embedding route logic in the server entry point makes the file harder to maintain as the project grows.

The health check logic should be moved into a dedicated controller while keeping the route definition separate. This refactoring will improve code organization, follow the project's separation of concerns, and make future enhancements to the health endpoint easier.


✅ Tasks

  • Create a dedicated health controller (e.g. controllers/healthController.js).
  • Move the existing health check logic into the controller.
  • Create a dedicated route file (e.g. routes/healthRoutes.js).
  • Register the health route from the route file instead of defining it directly in the server file.
  • Ensure the endpoint URL (/health) and response format remain unchanged.
  • Remove the inline health check implementation from the server file.

🎯 Expected Outcome

  • Cleaner and more maintainable server entry point.
  • Health check logic is separated from application bootstrap logic.
  • Easier to extend the health endpoint in the future.
  • No changes to the existing API response or endpoint behavior.

📂 Suggested Project Structure

src/
├── controllers/
│   └── healthController.js
├── routes/
│   └── healthRoutes.js
├── app.js

✅ Acceptance Criteria

  • A dedicated health controller has been created.
  • A dedicated health route file has been created.
  • The /health endpoint continues to return the same response.
  • The main server file no longer contains inline health check logic.
  • Existing functionality remains unchanged.
  • No existing tests fail after the refactor.

📝 Notes

This is a refactoring task focused on improving project structure and maintainability. The response format, endpoint path, and existing functionality must remain unchanged.

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