Skip to content

Add Hono health-check integration with options-first API, typed variables support, and integration coverage#161

Merged
arthurfiorette merged 14 commits into
mainfrom
copilot/add-hono-integration-and-tests
May 13, 2026
Merged

Add Hono health-check integration with options-first API, typed variables support, and integration coverage#161
arthurfiorette merged 14 commits into
mainfrom
copilot/add-hono-integration-and-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 13, 2026

This PR adds first-class Hono support so Medicus can expose health endpoints in Hono apps with the same HTTP semantics used by existing integrations. It also aligns docs/navigation and package metadata so the integration is discoverable and install-safe.

  • Integration: createHonoHealthCheckHandler

    • Adds src/integrations/hono.ts with a Hono handler factory backed by shared HTTP utilities.
    • Accepts Medicus options directly (Fastify/Avvio-style), without requiring a pre-created Medicus instance.
    • Supports the existing query contract: debug, last, and simulate=healthy|degraded|unhealthy.
    • Returns JSON body + status mapping (200 for healthy/degraded, 503 for unhealthy), with configurable response headers.
    • Uses the current Hono request context (c) as the Medicus context for checkers (no custom context override path).
    • Preserves cached last behavior for HTTP responses while using request-scoped Medicus instances.
  • Typing support for Hono context variables

    • Exports MedicusVariables<E, P, I> so users can type-safe c.set('medicus', ...) and c.get('medicus').
    • Propagates Hono Context<E, P, I> generics through Hono integration types so custom context generics are preserved.
  • Unit coverage for Hono behavior

    • Adds test/integrations/hono.test.ts.
    • Covers default route behavior, debug output toggling, cached-last responses, simulated status overrides, custom headers, and default request-context access.
  • Docs and navigation updates

    • Adds docs/integrations/hono.md with usage, query params, and options.
    • Updates integrations index and VitePress sidebar to include Hono.
    • Updates examples to reflect the options-first Hono API and typed variable usage.
  • Package metadata

    • Adds hono as an optional peer dependency and as a dev dependency for local test execution.
    • Bumps package patch version to 1.3.1.
import { Hono } from 'hono';
import { HealthStatus } from 'medicus';
import { createHonoHealthCheckHandler } from 'medicus/hono';

const app = new Hono();

app.get(
  '/health',
  createHonoHealthCheckHandler({
    checkers: {
      database: () => HealthStatus.HEALTHY
    }
  })
);

@arthurfiorette arthurfiorette marked this pull request as ready for review May 13, 2026 04:01
Copilot AI temporarily deployed to github-pages May 13, 2026 04:01 Inactive
Copilot AI temporarily deployed to github-pages May 13, 2026 04:01 Inactive
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

❌ Patch coverage is 99.22481% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.30%. Comparing base (c3a560a) to head (6df13a8).

Files with missing lines Patch % Lines
src/integrations/hono.ts 99.08% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #161      +/-   ##
==========================================
+ Coverage   98.21%   98.30%   +0.08%     
==========================================
  Files          14       15       +1     
  Lines        1064     1179     +115     
  Branches       75       77       +2     
==========================================
+ Hits         1045     1159     +114     
  Misses         13       13              
- Partials        6        7       +1     

☔ 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.

@arthurfiorette
Copy link
Copy Markdown
Owner

@copilot can you make it just like fastify or avvio integration where we pass medicus options directly instead of having to create a medicus instance separately?

Copy link
Copy Markdown
Owner

@arthurfiorette arthurfiorette left a comment

Choose a reason for hiding this comment

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

Please also bump a patch version of this package

Comment thread src/integrations/hono.ts Outdated
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 13, 2026

@copilot can you make it just like fastify or avvio integration where we pass medicus options directly instead of having to create a medicus instance separately?

Done in a941e78. createHonoHealthCheckHandler now accepts Medicus options directly (no pre-created Medicus required), and it now defaults checker context to Hono’s request context (c) unless an explicit context is provided.

Copilot AI changed the title Add Hono health-check integration with aligned docs and integration coverage Add Hono health-check integration with options-first API, request-context support, and integration coverage May 13, 2026
Copilot AI requested a review from arthurfiorette May 13, 2026 11:52
Comment thread src/integrations/hono.ts Outdated
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 13, 2026

Please also bump a patch version of this package

Done in 0f7d07f (and preserved in aedcb07). Package version is now bumped to 1.3.1.

Copilot AI changed the title Add Hono health-check integration with options-first API, request-context support, and integration coverage Add Hono health-check integration with options-first API, typed variables support, and integration coverage May 13, 2026
Copilot AI requested a review from arthurfiorette May 13, 2026 12:06
@arthurfiorette arthurfiorette merged commit 1755671 into main May 13, 2026
5 checks passed
@arthurfiorette arthurfiorette deleted the copilot/add-hono-integration-and-tests branch May 13, 2026 13:35
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.

2 participants