New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

pms_md

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pms_md

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

latest
Source
npmnpm
Version
1.0.7
Version published
Maintainers
1
Created
Source

🚀 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: ['admin@example.com']
    }
  }
});

// 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

DatabaseTypePackageStatus
MongoDBNoSQLmongoose
PostgreSQLSQLpg
MySQLSQLmysql2
MariaDBSQLmariadb
MSSQLSQLmssql
SQLiteSQLsqlite3
RedisCacheioredis
CouchDBNoSQLnano
CassandraNoSQLcassandra-driver
ElasticsearchSearch@elastic/elasticsearch
DynamoDBCloud@aws-sdk/client-dynamodb
Neo4jGraphneo4j-driver
SequelizeORMsequelize

📧 Email Notifications

Gmail Setup

EMAIL_USER=your-email@gmail.com
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: ['admin@example.com', 'team@example.com']
    }
  }
});

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: ['admin@example.com']
    },
    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

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

Database Connection Failures

  • Verify database driver is installed
  • Check connection credentials
  • Ensure database server is running
  • Review database-specific logs

High Memory Usage

  • Adjust monitoring.interval to reduce frequency
  • Reduce logging.maxFiles retention period
  • 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

Keywords

proses

FAQs

Package last updated on 07 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts