Registry / devops / exframe-health

exframe-health

JSON →
library1.9.0jsnpmunverified

A health check framework for microservices built on the exframe stack. Version 1.9.0 supports liveness and readiness probes for Kubernetes, with custom health checks, timeout-based and user-controlled promotion of failing checks from readiness to liveness. It integrates automatically with exframe-service and exframe-rest to expose GET health endpoints. Requires Node >=14 and peer dependency exframe-logger 3.x. Differentiators include built-in promotable check types and tight exframe ecosystem integration.

npm install exframe-health
INSTALL
IMPORT
SIG · EXFRAME-HEALTH
E
exframe-health
devopsjavascriptv1.9.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import health from 'exframe-health'
const health = require('exframe-health')
Package ships TypeScript types and is ESM-friendly; default export works with both import and require.
ProbeTypes
import { ProbeTypes } from 'exframe-health'
import { ProbeTypes } from 'exframe-health/ProbeTypes'
ProbeTypes is a named export, not a submodule.
PromotionTypes
import { PromotionTypes } from 'exframe-health'
Named export available since v1.0.0.

Adds a custom MongoDB health check using async function, then retrieves and removes it.

import health from 'exframe-health'; import mongoose from 'mongoose'; // Add a custom health check for MongoDB const checkMongoose = async () => { if (mongoose.connection.readyState === 1) { return { status: 200, message: 'OK' }; } else { return { status: 503, message: 'Service Unavailable' }; } }; health.add('MongoDB', checkMongoose); // Retrieve all health checks console.log(health.get()); // Check health (used internally by exframe-rest) // health.check(req, res); // Remove a health check health.remove('MongoDB');
Debug
Known issues
gotchaThe check function must return a Promise that resolves to an object with status and message; rejecting with a non-object will cause an error.
fix
Always wrap reject in an object: Promise.reject({ status: 503, message: '...' })
affects: <2.0.0
deprecatedThe 'check' method with req/res parameters is deprecated; use the integrated exframe-rest routes instead.
fix
Remove manual calls to health.check() and ensure exframe-rest is configured to auto-add routes.
affects: >=1.5.0 <2.0.0
breakingIn version 1.0.0, the default check type changed from 'Liveness' to 'Promotable' with timeout promotion.
fix
If you relied on old default, explicitly set { checkType: 'Liveness' } when adding checks.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: health.add is not a function
Using a named import or destructuring when default export is required.
fix
Use `import health from 'exframe-health'` (default import) instead of `import { health }`.
UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property 'status' of ... as it is undefined
The check function rejected with a non-object or didn't return a status property.
fix
Ensure the promise always resolves or rejects with an object containing status and message.
Upgrade
Version history
1.9.0latest on npm
Audit
Dependencies
exframe-loggerrequiredpeer dependency required for logging within health checks
Agent activity
2 hits · last 30 days
node
2
Resources
exframe-health — npm install exframe-health · libregistry