Skip to content

feat: Add health check endpoint and documentation#95

Open
metaforx wants to merge 3 commits intodjango-cms:mainfrom
metaforx:feat/api-health
Open

feat: Add health check endpoint and documentation#95
metaforx wants to merge 3 commits intodjango-cms:mainfrom
metaforx:feat/api-health

Conversation

@metaforx
Copy link
Collaborator

@metaforx metaforx commented Mar 12, 2026

fix #93

  • Add a simple API health endpoint for API uptime monitoring.
  • Update documentation

Summary by Sourcery

Add a minimal API health check endpoint and document its availability.

New Features:

  • Introduce a /api/healthcheck/ endpoint that returns a simple JSON status payload for monitoring.

Documentation:

  • Document the new healthcheck endpoint in the README and API reference.

Tests:

  • Add an endpoint test verifying the healthcheck returns HTTP 200 and the expected JSON body.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 12, 2026

Reviewer's Guide

Adds a minimal read-only health check endpoint at /api/healthcheck/, wires it into the URL configuration, documents it in both README and Sphinx reference docs, and introduces a small test to ensure it returns the expected payload and status code.

Sequence diagram for the new health check request flow

sequenceDiagram
    actor MonitoringTool
    participant DjangoURLResolver
    participant HealthCheckView
    participant ResponseObject

    MonitoringTool->>DjangoURLResolver: HTTP GET /api/healthcheck/
    DjangoURLResolver->>HealthCheckView: dispatch(request)
    HealthCheckView->>HealthCheckView: get(request)
    HealthCheckView-->>ResponseObject: create Response {status: ok}
    ResponseObject-->>MonitoringTool: HTTP 200 {"status": "ok"}
Loading

Class diagram for the new HealthCheckView endpoint

classDiagram
    class APIView {
    }

    class HealthCheckView {
        + http_method_names: tuple
        + get(request): Response
    }

    APIView <|-- HealthCheckView
Loading

File-Level Changes

Change Details Files
Introduce a minimal DRF-based health check API endpoint for uptime monitoring.
  • Add HealthCheckView subclassing APIView, restricting allowed methods to GET and OPTIONS.
  • Implement GET handler returning a fixed JSON body with status set to "ok".
djangocms_rest/views.py
Expose the health check endpoint in the public API routing.
  • Register healthcheck/ URL pattern pointing to HealthCheckView and name the route "healthcheck".
djangocms_rest/urls.py
Document the new health check endpoint in top-level and reference documentation.
  • Add /api/healthcheck/ row to the public endpoints table in the README.
  • Tidy README blockquote formatting around the Documentation note.
  • Create a Sphinx reference stub file for the healthcheck endpoint (content to be filled in or referenced elsewhere).
README.md
docs/source/reference/index.rst
docs/source/reference/healthcheck.rst
Add test coverage for the health check endpoint behavior.
  • Create a test case using BaseCMSRestTestCase and DRF reverse to hit the healthcheck endpoint.
  • Assert 200 OK response and exact JSON payload {"status": "ok"}.
tests/endpoints/test_healthcheck.py

Possibly linked issues

  • #feat: api health endpoint: PR implements the requested health endpoint (status ok), adds tests, and documents it, fulfilling the issue.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.03%. Comparing base (7f76592) to head (8d4d305).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #95      +/-   ##
==========================================
+ Coverage   91.98%   92.03%   +0.04%     
==========================================
  Files          19       19              
  Lines         886      891       +5     
  Branches      100      100              
==========================================
+ Hits          815      820       +5     
  Misses         44       44              
  Partials       27       27              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="docs/source/reference/index.rst" line_range="8" />
<code_context>

 OpenAPI Documentation
 ---------------------
- We recommend to use the :doc:`../tutorial/03-openapi-documentation` guide to setup a browsable OpenAPI documentation. 
- This will automatically generate the latest endpoints and their documentation. 
+ We recommend to use the :doc:`../tutorial/03-openapi-documentation` guide to setup a browsable OpenAPI documentation.
</code_context>
<issue_to_address>
**suggestion (typo):** Consider improving the grammar in this sentence ("recommend using" and "set up").

You could rephrase this to: "We recommend using the :doc:`../tutorial/03-openapi-documentation` guide to set up browsable OpenAPI documentation."

```suggestion
 We recommend using the :doc:`../tutorial/03-openapi-documentation` guide to set up browsable OpenAPI documentation.
```
</issue_to_address>

### Comment 2
<location path="docs/source/reference/healthcheck.rst" line_range="1" />
<code_context>
+Healthcheck Endpoint
+====================
+
</code_context>
<issue_to_address>
**nitpick (typo):** Standardize the spelling of "health check" in the title with the rest of the document.

The title uses “Healthcheck” (one word), but the rest of the document uses “health check.” Please update the title to “Health Check Endpoint” for consistency with the body and README.

```suggestion
Health Check Endpoint
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

metaforx and others added 2 commits March 12, 2026 08:37
nitpick (typo)

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Suggestion (typo)

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@metaforx metaforx requested a review from fsbraun March 12, 2026 07:39
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.

feat: api health endpoint

1 participant