Overview & Quick Start
Service Health Orchestration
@nexload-sdk/healthcheck
v4.1.0 Stable ReleasedRuntime-neutral health orchestration and monitoring report foundation for production services.
Node.jsBunedge-safe core
@nexload-sdk/healthcheck provides a runtime-neutral health orchestration engine for modern backend services. It manages checks, collectors, timeouts, cancellation, and status aggregation, returning a deterministic HealthReport.
10-Second Code Snippet
Section titled “10-Second Code Snippet”import { createHealthManager, memoryCheck, shutdownCheck } from "@nexload-sdk/healthcheck";
export const health = createHealthManager({ service: { name: "api-service", version: "1.0.0" }, checks: [shutdownCheck(), memoryCheck()],});
// Run readiness probe for Kubernetes / Dokploy / Dockerconst report = await health.run("readiness");console.log(report.status); // "ok" | "degraded" | "unhealthy"What You Get
Section titled “What You Get”- Multi-Scope Orchestration: Native support for
liveness,readiness,startup, and protecteddiagnosticsscopes. - Checks vs. Collectors:
- Check: Can impact aggregate service status (e.g. database connectivity, Redis ping, shutdown signals).
- Collector: Observational only; captures telemetry and measurements (e.g. CPU load, memory RSS) without triggering container restarts.
- Resilient Execution: Enforces per-check timeouts, retry policies, and graceful degradation.
- Sensitive Data Redaction: Automatic masking of database credentials, authorization tokens, and private hostnames in error outputs.
- Runtime Neutrality: Pure TypeScript core with zero Node-only assumptions; runs seamlessly on Node.js, Bun, and edge runtimes.
Installation & Requirements
Section titled “Installation & Requirements”pnpm add @nexload-sdk/healthcheckWith alternative package managers:
# npmnpm install @nexload-sdk/healthcheck
# bunbun add @nexload-sdk/healthcheckRequires Node >=20.9.0 or Bun >=1.0.0. The package is ESM-only and side-effect free.
Core Concepts: The Four Scopes
Section titled “Core Concepts: The Four Scopes”| Scope | Probe Question | Failure Consequence | Recommended Checks |
|---|---|---|---|
liveness | Is the process deadlocked or stuck in an unrecoverable state? | Container / process restart | Memory leak thresholds, shutdown signal, event loop freeze. Never downstream databases! |
readiness | Can this replica accept incoming client traffic? | Temporarily removed from load balancer pool | Database availability, Redis connection, cache warm status. |
startup | Has slow initialization or schema migration finished? | Delays liveness evaluation during boot | Database migrations, asset pre-compilation. |
diagnostics | What is the detailed operational health state? | Protected behind auth token | Detailed memory breakdown, active connections, queue depth. |
Quick Start: Creating a Production Manager
Section titled “Quick Start: Creating a Production Manager”import { createHealthManager, memoryCheck, runtimeInfoCheck, shutdownCheck,} from "@nexload-sdk/healthcheck";
export const health = createHealthManager({ service: { name: "user-service", version: process.env.APP_VERSION ?? "1.0.0", }, checks: [ shutdownCheck(), runtimeInfoCheck(), memoryCheck({ heapUsedPercent: 90, // Degraded above 90% }), ],});
// Execute readiness probeconst report = await health.run("readiness");if (report.status === "unhealthy") { process.exitCode = 1;}Next Steps
Section titled “Next Steps”- Explore Production Guides & Custom Checks for database checks, timeout policies, and status aggregation rules.
- View the complete API Reference & Signatures for all exported symbols and configuration types.