express-healthcheck is a lightweight middleware designed to provide basic health check endpoints for Express.js applications. Released as version 0.1.0 over ten years ago (last published in March 2016), the package is currently unmaintained and effectively abandoned by its original author. It offers a minimal interface to expose an uptime metric and allows for custom `healthy` and `test` functions to provide more application-specific health status, returning a 200 status code with a JSON payload. Unlike more modern and actively maintained health check libraries, it lacks features such as detailed dependency checks, async/await support, built-in security mechanisms, or explicit ESM compatibility, making it suitable only for extremely simple monitoring scenarios or as a historical reference.
npm install express-healthcheckVerified import paths — ran on the pinned version, not inferred.
Demonstrates setting up a basic health check and a customized health check endpoint with `express-healthcheck` in an Express application. It includes a simulated asynchronous test for a dependency and a custom healthy response.
Consider migrating to actively maintained health check middleware packages like `express-healthchecker`, `express-actuator-healthcheck`, or implementing custom health check logic for better control and security.
Always use `const expressHealthcheck = require('express-healthcheck');` for this package. If using TypeScript, `import expressHealthcheck = require('express-healthcheck');` is the most robust option, or ensure `esModuleInterop` is enabled in your `tsconfig.json` to allow `import expressHealthcheck from 'express-healthcheck';`.If your health check logic involves asynchronous operations (e.g., database queries, external API calls), you must wrap them to fit the expected synchronous return or callback pattern. For complex async checks, a more modern health check library or custom middleware would be more appropriate.
Ensure you call the imported module: `app.use('/health', require('express-healthcheck')());` or `app.use('/health', expressHealthcheck());` if you've assigned the result of `require()` to `expressHealthcheck`.Revert to CommonJS `require()` syntax: `const expressHealthcheck = require('express-healthcheck');`. If you must use ESM for your project, consider using a more modern health check library that offers explicit ESM support.No dependency data recorded yet.