The `server-health` library provides a standardized `/health` HTTP endpoint for various Node.js web frameworks, including Express, Fastify, Restify, Hapi, and vanilla HTTP servers. It offers vital service information such as overall status, uptime, package metadata (name, description, version, repository), environment details (nodeEnv, nodeVersion, pid, cwd), git commit information, and allows for pluggable custom connection checks (e.g., database, message queues). The current stable version is `7.0.0`, which primarily targets Node.js `v20.0.0` or higher, having dropped support for Node.js v18 and specific Restify versions on newer Node environments. The library focuses on providing a detailed, extensible health check solution without imposing a specific framework, making it highly adaptable. Key differentiators include server-side response filtering for specific data points and a comprehensive set of diagnostic data provided by default.
npm install server-healthVerified import paths — ran on the pinned version, not inferred.
Demonstrates initializing `server-health` with a Fastify server, adding custom connection checks, and exposing the `/health` endpoint.
Upgrade your Node.js runtime to version 20.0.0 or newer. Consider using Node.js LTS versions for stability.
If using Restify on Node.js v24, consider staying on `server-health` v6.x or migrating your application to use a different framework like Fastify or Express, or a newer version of Restify if available and compatible.
Upgrade your Node.js runtime to version 18.0.0 or newer (for v6.x) or to v20.0.0 or newer (for v7.x).
For ESM projects, use `import serverHealth from 'server-health';`. Ensure your `package.json` specifies `"type": "module"` or uses `.mjs` extensions where appropriate.
Run `npm install server-health` or `yarn add server-health` to install the package.
Ensure you are using `const serverHealth = require('server-health');` for CommonJS or `import serverHealth from 'server-health';` for ESM, and that the package is correctly installed.Provide a valid string for the framework: `'restify'`, `'express'`, `'hapi'`, `'fastify'`, or `'http'` (for vanilla Node.js `http` server).
No dependency data recorded yet.