Hono Third-Party ​
Hono is a small, fast, and standards-based web framework that runs on Node.js and edge runtimes.
You can integrate Medicus with your Hono application by attaching the createHonoHealthCheckHandler to a route:
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
}
})
);By default, checkers receive the current Hono request context (c) as the Medicus context. The underlying Medicus instance is created with context: null and each request passes c per check.
You can use MedicusVariables to type-safe c.set('medicus', ...) / c.get('medicus'):
import type { MedicusVariables } from 'medicus/hono';
type AppEnv = MedicusVariables;The health handler does c.set('medicus', medicus) so other middleware/routes can read the same instance from request context.
If your Hono app defines custom Bindings or Variables, pass the same app type to createHonoHealthCheckHandler. TypeScript cannot infer that type from the surrounding app.get(...) call, so the explicit generic is required for typed checker context.
import { Hono } from 'hono';
import { HealthStatus } from 'medicus';
import { createHonoHealthCheckHandler } from 'medicus/hono';
type App = {
Bindings: {
RELEASE: string;
};
Variables: {
db: {
healthCheck(): Promise<void>;
};
requestId: string;
};
};
const app = new Hono<App>();
app.get(
'/health',
createHonoHealthCheckHandler<App>({
debug: true,
checkers: {
async database(ctx) {
await ctx.get('db').healthCheck();
return {
status: HealthStatus.HEALTHY,
debug: {
release: ctx.env.RELEASE,
requestId: ctx.get('requestId')
}
};
}
}
})
);Edge Runtime Note ​
On edge runtimes (for example Cloudflare Workers), application instances are typically spun up per request. Because of that lifecycle, background checks are not suitable and should remain disabled (backgroundCheckInterval unset).
Query Parameters ​
?debug- Include debug information?last- Return cached result?simulate=unhealthy|degraded|healthy- Simulate status
Options ​
import { HealthChecker } from 'medicus';
interface HonoHealthCheckOptions {
checkers?: Record<string, HealthChecker>; // Medicus checkers
debug?: boolean; // Include debug info by default
headers?: Record<string, string>; // Custom response headers
}For more details about Hono, visit the Hono documentation.