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

health-actuator

v1.0.2

Published

Actuator-like health monitoring library for Node.js with auto-detection of databases and Redis

Readme

Health Actuator

A Spring Boot Actuator-like health monitoring library for Node.js. Automatically detects database and Redis connections and provides health check endpoints with zero configuration.

Features

  • 🏥 Auto-Detection - Automatically detects MongoDB, PostgreSQL, MySQL, Prisma, Sequelize, and Redis connections
  • 📊 Health Checks - Aggregate health status from all detected services
  • 📈 Metrics - System and application metrics
  • ℹ️ Info - Application information, environment variables, and system details
  • 🔍 Liveness & Readiness - Kubernetes-ready probes

Installation

npm install @akshat001/health-actuator

Quick Start (Zero Configuration!)

import express from 'express';
import { useHealthActuator } from '@akshat001/health-actuator';

const app = express();

// That's it! Auto-detects DB and Redis, all endpoints available
useHealthActuator(app);

app.listen(3000);

Endpoints automatically available:

  • GET /health - Full health check (shows DB, Redis status)
  • GET /health/liveness - Liveness probe
  • GET /health/readiness - Readiness probe
  • GET /info - Application info + environment variables
  • GET /metrics - System metrics

Auto-Detection

The library automatically detects:

Databases

  • MongoDB (mongoose) - Detects mongoose.connection
  • PostgreSQL (pg) - Detects global.pgPool
  • MySQL (mysql2) - Detects global.mysqlPool
  • Prisma - Detects PrismaClient instances
  • Sequelize - Detects global.sequelize

Redis

  • ioredis - Auto-detects ioredis clients
  • node-redis - Detects global.redisClient

Manual Registration (Optional)

If auto-detection doesn't find your connections, register them manually:

import express from 'express';
import { 
  useHealthActuator, 
  registerPostgres, 
  registerRedis 
} from '@akshat001/health-actuator';
import { Pool } from 'pg';
import { createClient } from 'redis';

const app = express();

// Your database setup
const dbPool = new Pool({ /* config */ });
const redisClient = createClient({ /* config */ });

// Register connections (optional - auto-detection works for most cases)
registerPostgres(dbPool);
registerRedis(redisClient);

// Setup health actuator
useHealthActuator(app);

app.listen(3000);

Example Responses

Health Endpoint (GET /health)

{
  "status": "UP",
  "components": {
    "mongodb": {
      "status": "UP",
      "details": { "message": "Database connection is healthy" }
    },
    "ioredis": {
      "status": "UP",
      "details": { "message": "Redis connection is healthy", "ping": "PONG" }
    }
  },
  "timestamp": "2024-01-22T09:00:00.000Z"
}

Info Endpoint (GET /info)

{
  "app": {
    "name": "my-app",
    "version": "1.0.0",
    "node": "v20.0.0"
  },
  "system": {
    "platform": "linux",
    "arch": "x64",
    "hostname": "server-01",
    "cpus": 4,
    "totalMemory": 8589934592,
    "freeMemory": 4294967296
  },
  "environment": {
    "NODE_ENV": "production",
    "PORT": "3000",
    "DATABASE_URL": "***",
    "REDIS_URL": "***"
  }
}

Metrics Endpoint (GET /metrics)

{
  "uptime": {
    "name": "uptime",
    "value": 3600,
    "unit": "seconds"
  },
  "memory": {
    "heap": {
      "used": { "name": "memory.heap.used", "value": 1048576, "unit": "bytes" },
      "total": { "name": "memory.heap.total", "value": 2097152, "unit": "bytes" }
    }
  },
  "cpu": {
    "user": { "name": "cpu.user", "value": 123456, "unit": "microseconds" }
  }
}

Complete Example

// src/app.ts
import express from 'express';
import mongoose from 'mongoose';
import { useHealthActuator } from '@akshat001/health-actuator';

const app = express();

// Your database connection (mongoose will be auto-detected)
mongoose.connect('mongodb://localhost:27017/mydb');

// Your Redis connection (if using ioredis, will be auto-detected)
// const redis = new Redis('redis://localhost:6379');

// Setup health actuator - auto-detects mongoose and redis!
useHealthActuator(app);

// Your routes
app.get('/', (req, res) => {
  res.json({ message: 'Hello World' });
});

app.listen(3000, () => {
  console.log('Server running on http://localhost:3000');
  console.log('Health: http://localhost:3000/health');
  console.log('Info: http://localhost:3000/info');
  console.log('Metrics: http://localhost:3000/metrics');
});

Custom Configuration (Optional)

import express from 'express';
import { useHealthActuator, CustomIndicator } from '@akshat001/health-actuator';

const app = express();

useHealthActuator(app, {
  basePath: '/actuator', // Custom base path
  customIndicators: [
    new CustomIndicator('external-api', async () => {
      const response = await fetch('https://api.example.com/health');
      return {
        status: response.ok ? 'UP' : 'DOWN',
        details: { statusCode: response.status }
      };
    })
  ]
});

app.listen(3000);

Environment Variables

You can configure via environment variables:

HEALTH_ACTUATOR_BASE_PATH=/actuator
HEALTH_ACTUATOR_ENABLE_HEALTH=true
HEALTH_ACTUATOR_ENABLE_METRICS=true
import { useHealthActuator, loadConfigFromEnv } from '@akshat001/health-actuator';

useHealthActuator(app, loadConfigFromEnv());

License

MIT