npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

express-health-probe

v1.0.0

Published

Enterprise-grade health and readiness checks for Express with graceful shutdown, caching, and monitoring support.

Downloads

11

Readme

express-health-probe

A simple, enterprise-ready healthcheck middleware for Express.js.

Provides perfect /health, /ready, and /metrics endpoints instantly. Built for modern cloud-native architectures like Kubernetes, Docker Swarm, and AWS ECS.


🚀 Features

  • Zero-Config Database Monitoring: Auto-detects Mongoose, Redis, and Postgres connections. No need to write custom ping functions!
  • Prometheus Built-in: Automatically tracks and exports metrics for Grafana.
  • Enterprise Safeguards: DDoS cache protection, automatic timeouts, and Graceful Shutdown signal trapping built in.
  • TypeScript Ready: Full code autocomplete and type definitions included natively.

📦 Installation

npm install express-health-probe express

💻 Usage

1. Basic (1-line setup)

Instantly adds highly-performant /health, /ready, and /metrics routes to your app.

import express from 'express';
import healthcheck from 'express-health-probe';

const app = express();

app.use(healthcheck());

app.listen(3000);

2. Advanced (The "Magic" Auto-Dependency Check)

Want to check if MongoDB or Redis is alive before saying the app is ready? Just pass the clients into the dependencies object. The package handles picking the right ping commands for you automatically!

import express from 'express';
import healthcheck from 'express-health-probe';
import mongoose from 'mongoose';
import { createClient } from 'redis';

const app = express();
const redisClient = createClient();

app.use(healthcheck({
  dependencies: {
    mongo: mongoose.connection,
    redis: redisClient
  }
}));

3. Enterprise (Kubernetes & Hooks)

For production builds, cache the database checks, configure timeouts, and hook into Datadog/OpenTelemetry easily.

app.use(healthcheck({
  // Protect your database from being pinged too often
  cacheDuration: 10000, 
  timeout: 5000, 
  
  // Cleanly shut down if Kubernetes kills the pod
  gracefulShutdown: true,
  onShutdown: async () => {
    console.log("Shutting down cleanly...");
    await mongoose.connection.close();
  },

  // Log failures securely to APM tracing tools
  onCheckFail: ({ path, error, duration }) => {
    console.error(`Check ${path} failed in ${duration}ms! ${error.message}`);
  }
}));

⚙️ Configuration Options

| Option | Type | Default | Description | |---|---|---|---| | path | string | '/health' | Path for Liveness probe (Are you running?) | | readyPath | string | '/ready' | Path for Readiness probe (Are DBs connected?) | | metricsPath | string | '/metrics' | Path for Prometheus exports | | dependencies | Object | {} | Map of Mongo, Redis, or Postgres clients to auto-check | | cacheDuration | number | 0 | MS to cache successful checks (database protection) | | timeout | number | 5000 | MS before a readiness check forcibly fails | | gracefulShutdown | boolean| false | Enable Kubernetes SIGTERM / SIGINT trapping | | exposeStackTraces| boolean| false | Export exact Error trace messages in your JSON | | onShutdown | Function | | Hook fired when process terminates via Graceful Shutdown | | onCheckStart | Function | | Hook fired precisely when a healthcheck starts | | onCheckSuccess| Function | | Hook fired precisely when a healthcheck successfully completes | | onCheckFail | Function | | Hook fired when a healthcheck fails |


❤️ Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.

📄 License

MIT License