@terreno/api-health
v57.6.1
Published
Health check plugin for @terreno/api — part of Terreno, the batteries-included TypeScript framework for universal apps.
Readme
@terreno/api-health
Health check plugin for @terreno/api.
Health check TerrenoPlugin for @terreno/api — adds a configurable GET /health endpoint with optional custom checks.
Install
bun add @terreno/api-health @terreno/apiQuick start
import {TerrenoApp} from "@terreno/api";
import {HealthApp} from "@terreno/api-health";
import mongoose from "mongoose";
import {User} from "./models/user";
const healthApp = new HealthApp({
path: "/health",
check: async () => {
try {
await mongoose.connection.db!.admin().ping();
return {healthy: true, details: {database: "connected"}};
} catch {
return {healthy: false, details: {database: "disconnected"}};
}
},
});
new TerrenoApp({userModel: User}).register(healthApp).start();Returns 200 with {healthy: true, ...} when healthy, 503 when healthy: false.
What's included
HealthApp—TerrenoPluginregistering a health endpointHealthOptions—enabled,path, and optional asynccheckfunctionHealthCheckResult—{healthy: boolean, details?: Record<string, unknown>}- Default behavior:
GET /healthreturns{healthy: true}when no custom check is provided - Supports load balancer probes, Kubernetes liveness/readiness, and database connectivity checks
Documentation
Full API reference: docs/reference/api-health.md
License and Contributing
Licensed under the MIT License. See CONTRIBUTING.md for contribution guidelines.
