{"id":47515,"library":"exframe-health","title":"exframe-health","description":"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.","status":"active","version":"1.9.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install exframe-health","lang":"bash","label":"npm"},{"cmd":"yarn add exframe-health","lang":"bash","label":"yarn"},{"cmd":"pnpm add exframe-health","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for logging within health checks","package":"exframe-logger","optional":false}],"imports":[{"note":"Package ships TypeScript types and is ESM-friendly; default export works with both import and require.","wrong":"const health = require('exframe-health')","symbol":"default","correct":"import health from 'exframe-health'"},{"note":"ProbeTypes is a named export, not a submodule.","wrong":"import { ProbeTypes } from 'exframe-health/ProbeTypes'","symbol":"ProbeTypes","correct":"import { ProbeTypes } from 'exframe-health'"},{"note":"Named export available since v1.0.0.","wrong":"","symbol":"PromotionTypes","correct":"import { PromotionTypes } from 'exframe-health'"}],"quickstart":{"code":"import health from 'exframe-health';\nimport mongoose from 'mongoose';\n\n// Add a custom health check for MongoDB\nconst checkMongoose = async () => {\n  if (mongoose.connection.readyState === 1) {\n    return { status: 200, message: 'OK' };\n  } else {\n    return { status: 503, message: 'Service Unavailable' };\n  }\n};\nhealth.add('MongoDB', checkMongoose);\n\n// Retrieve all health checks\nconsole.log(health.get());\n\n// Check health (used internally by exframe-rest)\n// health.check(req, res);\n\n// Remove a health check\nhealth.remove('MongoDB');","lang":"typescript","description":"Adds a custom MongoDB health check using async function, then retrieves and removes it."},"warnings":[{"fix":"Always wrap reject in an object: Promise.reject({ status: 503, message: '...' })","message":"The check function must return a Promise that resolves to an object with status and message; rejecting with a non-object will cause an error.","severity":"gotcha","affected_versions":"<2.0.0"},{"fix":"Remove manual calls to health.check() and ensure exframe-rest is configured to auto-add routes.","message":"The 'check' method with req/res parameters is deprecated; use the integrated exframe-rest routes instead.","severity":"deprecated","affected_versions":">=1.5.0 <2.0.0"},{"fix":"If you relied on old default, explicitly set { checkType: 'Liveness' } when adding checks.","message":"In version 1.0.0, the default check type changed from 'Liveness' to 'Promotable' with timeout promotion.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.9.0':16 '14':61 '3':68 'automat':45 'base':30 'built':10,73 'built-in':72 'check':6,27,38,76 'control':34 'custom':25 'depend':64 'differenti':70 'ecosystem':81 'endpoint':58 'exfram':2,13,48,52,66,80 'exframe-health':1 'exframe-logg':65 'exframe-rest':51 'exframe-servic':47 'expos':55 'fail':37 'framework':7 'get':56 'health':3,5,26,57 'includ':71 'integr':44,82 'javascript':83 'kubernet':23 'live':18,42 'logger':67 'microservic':9 'node':60 'peer':63 'probe':21 'promot':35,75 'readi':20,40 'requir':59 'rest':53 'servic':49 'stack':14 'support':17 'tight':79 'timeout':29 'timeout-bas':28 'type':77 'typescript':84 'user':33 'user-control':32 'version':15 'x':69","created_at":"2026-06-07T16:51:54.449160+00:00","updated_at":"2026-06-07T16:51:54.449160+00:00","problems":[{"fix":"Use `import health from 'exframe-health'` (default import) instead of `import { health }`.","cause":"Using a named import or destructuring when default export is required.","error":"TypeError: health.add is not a function"},{"fix":"Ensure the promise always resolves or rejects with an object containing status and message.","cause":"The check function rejected with a non-object or didn't return a status property.","error":"UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property 'status' of ... as it is undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://bitbucket.org/exzeo-usa/exframe#readme","github":null,"docs":null,"changelog":null,"pypi":null,"npm":"exframe-health","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}