Skip to content

feat(rest-api-protocol): migrate health_check context to contract-first architecture#1946

Merged
josecelano merged 3 commits into
torrust:developfrom
josecelano:1939-migrate-health-check-context
Jun 25, 2026
Merged

feat(rest-api-protocol): migrate health_check context to contract-first architecture#1946
josecelano merged 3 commits into
torrust:developfrom
josecelano:1939-migrate-health-check-context

Conversation

@josecelano

@josecelano josecelano commented Jun 24, 2026

Copy link
Copy Markdown
Member

Description

Implements SI-1: Migrate health_check context to contract-first architecture (sub-issue of #1938).

Changes

  • rest-api-protocol: Added v1::resources::health_check module with Status and Report DTOs, exported from resources/mod.rs.
  • axum-rest-api-server: Removed local resources.rs from health_check context. Handler now imports protocol DTOs from torrust_tracker_rest_api_protocol.
  • Test: Updated integration test to import DTOs from the protocol crate.
  • Spec: Updated docs/issues/open/1939-1938-si-1-migrate-health-check-context.md progress.

Verification

  • Protocol DTOs created and exported
  • Local DTOs removed from Axum server
  • Handler uses protocol DTOs
  • Pre-commit checks pass
  • Compilation verified for both affected packages
  • Pre-push checks (CI)

…st architecture

Move Status and Report DTOs from axum-rest-api-server to
rest-api-protocol. The health_check context now follows the
contract-first architecture pattern: protocol DTOs live in the
protocol crate, and the Axum handler imports from there.

- Create rest-api-protocol/src/v1/resources/health_check.rs
- Export new module from rest-api-protocol resources mod.rs
- Remove local resources.rs from axum-rest-api-server health_check
- Update handler and test imports to use protocol crate
Copilot AI review requested due to automatic review settings June 24, 2026 17:20
@josecelano josecelano self-assigned this Jun 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Migrates the REST API v1 health_check context to the contract-first architecture by moving its DTOs into rest-api-protocol, updating the Axum server to consume those protocol DTOs, and adjusting the integration test and EPIC/spec documentation accordingly.

Changes:

  • Added v1::resources::health_check DTOs (Status, Report) to torrust-tracker-rest-api-protocol and exported the module.
  • Updated axum-rest-api-server health_check handler to return protocol DTOs; removed the server-local DTO module.
  • Updated the REST API integration test and issue-spec/EPIC progress docs to reflect the migration.

Reviewed changes

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

Show a summary per file
File Description
packages/rest-api-protocol/src/v1/resources/mod.rs Exposes the new health_check protocol resource module.
packages/rest-api-protocol/src/v1/resources/health_check.rs Introduces contract DTOs for the /api/health_check endpoint.
packages/axum-rest-api-server/tests/server/v1/contract/context/health_check.rs Switches test DTO imports to the protocol crate.
packages/axum-rest-api-server/src/v1/context/health_check/resources.rs Removes server-local health_check DTOs (now owned by protocol crate).
packages/axum-rest-api-server/src/v1/context/health_check/mod.rs Updates endpoint docs to reference protocol resources.
packages/axum-rest-api-server/src/v1/context/health_check/handlers.rs Updates handler to use protocol DTOs.
docs/issues/open/1939-1938-si-1-migrate-health-check-context.md Updates SI-1 progress, but needs status/value alignment fixes (see PR comments).
docs/issues/open/1938-rest-api-contract-first-migration/EPIC.md Updates EPIC status/progress to reflect SI-1 completion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/axum-rest-api-server/src/v1/context/health_check/handlers.rs Outdated
Comment thread packages/axum-rest-api-server/src/v1/context/health_check/mod.rs Outdated
Comment thread docs/issues/open/1939-1938-si-1-migrate-health-check-context.md Outdated
…sed modules

- Rename v1/resources/ to v1/context/ with per-context subdirectories
- Each context has a resources/ subdirectory for DTO files
- Rename health_check/resources/health_check.rs to report.rs
- Update all Rust imports across the workspace
- Update EPIC and sub-issue specs to document the convention
- Fix module-level doc comment from `stats` to `health_check`
- Fix invalid JSON example (trailing comma, indentation)
- Fix implementation plan status values: `Completed` -> `DONE`
- Correct T5/T6 task descriptions
@josecelano

Copy link
Copy Markdown
Member Author

ACK 0591cf2

@josecelano josecelano merged commit e16e41e into torrust:develop Jun 25, 2026
16 checks passed
@josecelano josecelano linked an issue Jun 25, 2026 that may be closed by this pull request
5 tasks
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.

SI-1: Migrate health_check context to contract-first architecture

2 participants