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

pms_md

v1.0.7

Published

Comprehensive monitoring solution for Node.js applications with error tracking, health checks, multi-database support (MongoDB, PostgreSQL, MySQL, MSSQL, SQLite, Redis, Cassandra, Elasticsearch, DynamoDB, Neo4j, CouchDB), and multi-channel notifications

Downloads

410

Readme

🚀 PMS_MD - Comprehensive Node.js Monitoring Solution

npm version License: ISC Node.js

Production-ready monitoring solution for Node.js applications with comprehensive database support, error tracking, health checks, and multi-channel notifications.


✨ Features

  • 🎨 Beautiful UI Dashboard - One-line integration with stunning monitoring UI (NEW!)
  • 🗄️ 13+ Database Support - MongoDB, PostgreSQL, MySQL, MariaDB, MSSQL, SQLite, Redis, Cassandra, Elasticsearch, DynamoDB, Neo4j, CouchDB, Sequelize
  • 📧 Email Notifications - Automatic alerts for errors, crashes, and database failures
  • 📊 Health Monitoring - System resources (CPU, Memory), API errors, database connections
  • 🔔 Multi-Channel Alerts - Email, Slack, and custom webhooks
  • 📝 Advanced Logging - Winston-based logging with daily rotation and sanitization
  • 🛡️ Graceful Shutdown - Proper cleanup with email notifications on server shutdown
  • 🎯 Express Integration - Middleware for error handling, request logging, and health endpoints
  • 📈 Metrics & Analytics - Historical metrics tracking and dashboard endpoints

📦 Installation

npm install pms_md

Optional Database Drivers

Install only the database drivers you need:

# SQL Databases
npm install pg                          # PostgreSQL
npm install mysql2                      # MySQL
npm install mariadb                     # MariaDB
npm install mssql                       # MSSQL (SQL Server)
npm install sqlite3                     # SQLite

# NoSQL Databases
npm install mongoose                    # MongoDB
npm install nano                        # CouchDB
npm install cassandra-driver            # Cassandra

# Cache & Search
npm install ioredis                     # Redis
npm install @elastic/elasticsearch     # Elasticsearch

# Cloud Databases
npm install @aws-sdk/client-dynamodb    # DynamoDB

# Graph Databases
npm install neo4j-driver                # Neo4j

# ORM
npm install sequelize                   # Sequelize (MySQL, PostgreSQL, SQLite, MSSQL)

🚀 Quick Start

Basic Setup

const express = require('express');
const NodeMonitor = require('pms_md');

const app = express();

// Initialize monitor
const monitor = new NodeMonitor({
  app: {
    name: 'my-app',
    environment: 'production'
  },
  notifications: {
    email: {
      enabled: true,
      smtp: {
        host: 'smtp.gmail.com',
        port: 587,
        secure: false,
        auth: {
          user: process.env.EMAIL_USER,
          pass: process.env.EMAIL_APP_PASSWORD
        }
      },
      from: process.env.EMAIL_USER,
      recipients: ['[email protected]']
    }
  }
});

// Add middleware
app.use(monitor.requestLogger());
app.use(monitor.errorMiddleware());

// Health endpoints
app.get('/health', monitor.healthCheckEndpoint());
app.get('/health/info', monitor.healthInfoEndpoint());

// Start monitoring
monitor.start();

// Start server
const server = app.listen(3000, () => {
  console.log('Server running on port 3000');
});

// Graceful shutdown with email notifications
monitor.setupGracefulShutdown(server);

module.exports = app;

🎨 Beautiful Monitoring UI (NEW!)

One-Line Integration 🚀

Add a complete monitoring dashboard to your app with just one line of code:

const express = require('express');
const NodeMonitor = require('pms_md');

const app = express();

const monitor = new NodeMonitor({
  app: { name: 'My App' }
});

// ===== ONE LINE TO ENABLE ENTIRE UI! =====
monitor.serveUI(app);

monitor.start();
app.listen(3000);

What You Get

After calling monitor.serveUI(app), you get:

  • 🏠 Home Page - / - Navigation hub with quick links
  • 📊 Dashboard - /monitor/dashboard - Complete monitoring overview
  • 💚 Health Check - /health - Live health status with auto-refresh
  • 📈 Metrics - /monitor/metrics - Interactive charts (CPU, Memory)
  • 📋 Status - /monitor/status - Real-time status overview
  • 🚨 Error Logs - /monitor/error-logs - Error tracking

Features

Zero Configuration - Works out of the box ✅ No File Copying - Everything served from node_modulesBeautiful Design - Modern, responsive UI ✅ Real-time Updates - Auto-refresh dashboards ✅ Interactive Charts - Powered by Chart.js ✅ Dark/Light Theme - User preference support ✅ Content Negotiation - Supports both HTML and JSON

Advanced Configuration

// Custom base path
monitor.serveUI(app, {
  basePath: '/monitoring',
  appName: 'Production API',
  enableErrorLogs: true
});

// UI now available at:
// http://localhost:3000/monitoring/
// http://localhost:3000/monitoring/dashboard

Screenshots

Visit http://localhost:3000/ after starting your server to see the beautiful UI!

📚 Complete UI Integration Guide →


🗄️ Database Monitoring

MSSQL (SQL Server)

const sql = require('mssql');

const pool = await sql.connect({
  server: 'localhost',
  database: 'mydb',
  user: 'sa',
  password: 'password',
  options: {
    encrypt: true,
    trustServerCertificate: true
  }
});

monitor.registerDatabase('mssql', 'mssql', pool);

PostgreSQL

const { Pool } = require('pg');

const pool = new Pool({
  host: 'localhost',
  database: 'mydb',
  user: 'postgres',
  password: 'password'
});

monitor.registerDatabase('postgres', 'postgresql', pool);

MySQL / MariaDB

const mysql = require('mysql2/promise');

const pool = mysql.createPool({
  host: 'localhost',
  user: 'root',
  password: 'password',
  database: 'mydb'
});

monitor.registerDatabase('mysql', 'mysql2', pool);

MongoDB

const mongoose = require('mongoose');

await mongoose.connect('mongodb://localhost:27017/mydb');
monitor.registerDatabase('mongodb', 'mongoose', mongoose.connection);

Redis

const Redis = require('ioredis');

const redis = new Redis({
  host: 'localhost',
  port: 6379
});

monitor.registerDatabase('redis', 'redis', redis);

SQLite

const sqlite3 = require('sqlite3');
const db = new sqlite3.Database('./mydb.sqlite');

monitor.registerDatabase('sqlite', 'sqlite', db);

Cassandra

const cassandra = require('cassandra-driver');

const client = new cassandra.Client({
  contactPoints: ['localhost'],
  localDataCenter: 'datacenter1'
});

await client.connect();
monitor.registerDatabase('cassandra', 'cassandra', client);

See complete database guide →


📊 Supported Databases

| Database | Type | Package | Status | |----------|------|---------|--------| | MongoDB | NoSQL | mongoose | ✅ | | PostgreSQL | SQL | pg | ✅ | | MySQL | SQL | mysql2 | ✅ | | MariaDB | SQL | mariadb | ✅ | | MSSQL | SQL | mssql | ✅ | | SQLite | SQL | sqlite3 | ✅ | | Redis | Cache | ioredis | ✅ | | CouchDB | NoSQL | nano | ✅ | | Cassandra | NoSQL | cassandra-driver | ✅ | | Elasticsearch | Search | @elastic/elasticsearch | ✅ | | DynamoDB | Cloud | @aws-sdk/client-dynamodb | ✅ | | Neo4j | Graph | neo4j-driver | ✅ | | Sequelize | ORM | sequelize | ✅ |


📧 Email Notifications

Gmail Setup

  1. Enable 2-Step Verification in your Google Account
  2. Generate App Password: https://myaccount.google.com/apppasswords
  3. Configure environment variables:
[email protected]
EMAIL_APP_PASSWORD=your-16-char-app-password

Configuration

const monitor = new NodeMonitor({
  notifications: {
    email: {
      enabled: true,
      smtp: {
        host: 'smtp.gmail.com',
        port: 587,
        secure: false,
        auth: {
          user: process.env.EMAIL_USER,
          pass: process.env.EMAIL_APP_PASSWORD
        }
      },
      from: process.env.EMAIL_USER,
      recipients: ['[email protected]', '[email protected]']
    }
  }
});

Notification Types

  • Server Errors - Uncaught exceptions and unhandled rejections
  • Database Failures - Connection loss and recovery
  • Graceful Shutdown - Server shutdown notifications
  • API Errors - HTTP 500 errors and critical failures

🎯 Express Middleware

Error Handling

// Automatic error tracking and email notifications
app.use(monitor.errorMiddleware());

Request Logging

// Log all HTTP requests with sanitization
app.use(monitor.requestLogger());

404 Handler

// Handle 404 errors
app.use(monitor.notFoundHandler());

📈 Health Endpoints

Basic Health Check

app.get('/health', monitor.healthCheckEndpoint());

Response:

{
  "status": "healthy",
  "timestamp": "2025-11-17T12:00:00.000Z",
  "uptime": 3600,
  "databases": {
    "mssql": "connected",
    "redis": "connected"
  }
}

Detailed Health Info

app.get('/health/info', monitor.healthInfoEndpoint());

Response:

{
  "status": "healthy",
  "timestamp": "2025-11-17T12:00:00.000Z",
  "uptime": 3600,
  "system": {
    "cpu": 45.2,
    "memory": {
      "used": 512,
      "total": 8192,
      "percentage": 6.25
    }
  },
  "databases": {
    "mssql": {
      "status": "connected",
      "type": "mssql",
      "version": "Microsoft SQL Server 2019...",
      "connections": 10
    }
  }
}

🛡️ Graceful Shutdown

Automatically send email notifications when your server shuts down:

const server = app.listen(3000);

// Setup graceful shutdown with email notifications
monitor.setupGracefulShutdown(server);

Features:

  • ✅ Sends email notification on shutdown
  • ✅ Closes all database connections
  • ✅ Stops all monitoring intervals
  • ✅ Handles SIGTERM and SIGINT signals
  • ✅ Prevents memory leaks

📝 Advanced Configuration

Full Configuration Example

const monitor = new NodeMonitor({
  app: {
    name: 'my-production-app',
    environment: 'production',
    version: '1.0.0'
  },
  monitoring: {
    enabled: true,
    interval: 60000,  // Check every 60 seconds
    systemMetrics: true,
    apiErrors: true
  },
  database: {
    enabled: true,
    checkInterval: 30000,  // Check every 30 seconds
    queryTimeout: 5000,
    consecutiveFailuresThreshold: 3
  },
  notifications: {
    email: {
      enabled: true,
      smtp: {
        host: 'smtp.gmail.com',
        port: 587,
        secure: false,
        auth: {
          user: process.env.EMAIL_USER,
          pass: process.env.EMAIL_APP_PASSWORD
        }
      },
      from: process.env.EMAIL_USER,
      recipients: ['[email protected]']
    },
    slack: {
      enabled: false,
      webhookUrl: process.env.SLACK_WEBHOOK_URL
    }
  },
  logging: {
    level: 'info',
    directory: './logs',
    maxFiles: '14d',
    maxSize: '20m',
    sanitize: true
  }
});

📚 API Reference

Core Methods

monitor.start()

Start all monitoring services.

monitor.stop()

Stop all monitoring services.

monitor.registerDatabase(name, type, connection)

Register a database for monitoring.

Parameters:

  • name (string) - Unique identifier for the database
  • type (string) - Database type (e.g., 'mssql', 'postgresql', 'mongodb')
  • connection (object) - Database connection object

monitor.getDatabaseStats(name)

Get statistics for a specific database.

Returns: Promise

monitor.getAllDatabaseStats()

Get statistics for all registered databases.

Returns: Promise

monitor.setupGracefulShutdown(server)

Setup graceful shutdown with email notifications.

Parameters:

  • server (object) - HTTP server instance

Middleware Methods

monitor.errorMiddleware()

Express middleware for error handling.

monitor.requestLogger()

Express middleware for request logging.

monitor.notFoundHandler()

Express middleware for 404 errors.

Endpoint Methods

monitor.healthCheckEndpoint()

Express endpoint handler for basic health check.

monitor.healthInfoEndpoint()

Express endpoint handler for detailed health information.

monitor.dashboardEndpoint()

Express endpoint handler for monitoring dashboard.


🧪 Testing

Run the comprehensive test suite:

node test-all-databases.js

Test Coverage:

  • ✅ Package loading
  • ✅ Monitor instantiation
  • ✅ Database registration (all 13+ types)
  • ✅ Health checks
  • ✅ Statistics retrieval
  • ✅ Peer dependencies

📖 Documentation


🔧 Troubleshooting

Email Notifications Not Working

  1. Check Gmail App Password is correct (16 characters, no spaces)
  2. Verify 2-Step Verification is enabled
  3. Check environment variables are loaded
  4. Review logs in ./logs directory

Database Connection Failures

  1. Verify database driver is installed
  2. Check connection credentials
  3. Ensure database server is running
  4. Review database-specific logs

High Memory Usage

  1. Adjust monitoring.interval to reduce frequency
  2. Reduce logging.maxFiles retention period
  3. Disable unused monitoring features

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


📄 License

ISC License - see LICENSE file for details


👤 Author

Manish Proses


🙏 Acknowledgments

Built with:


📊 Version History

v1.0.3 (Latest)

  • ✅ Added MSSQL (SQL Server) support
  • ✅ Added MariaDB support
  • ✅ Added SQLite support
  • ✅ Added CouchDB support
  • ✅ Added Cassandra support
  • ✅ Added Elasticsearch support
  • ✅ Added DynamoDB support
  • ✅ Added Neo4j support
  • ✅ Comprehensive documentation
  • ✅ 100% test coverage

v1.0.2

  • ✅ Enhanced MySQL2 support (v2 and v3)
  • ✅ Added Sequelize ORM support
  • ✅ Improved peer dependencies

v1.0.1

  • ✅ Initial release
  • ✅ MongoDB, PostgreSQL, MySQL, Redis support
  • ✅ Email notifications
  • ✅ Health monitoring

🚀 What's Next?

Planned features for future releases:

  • TypeScript definitions
  • Prometheus metrics export
  • Custom alerting rules
  • Performance profiling
  • Distributed tracing

Made with ❤️ for the Node.js community