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

v1.0.1

Published

A lightweight, zero-dashboard monitoring helper for Express applications that detects slow APIs and server crashes.

Readme

express-watchdog

A lightweight, zero-dashboard monitoring helper for Express applications. Keep an eye on your APIs and get alerted when things go slow or the server crashes—all without any complex setup!

Features

  • Auto-pilot Monitoring: Automatically detects slow API responses.
  • Crash Protection: Listens for process-level errors and unhandled rejections.
  • Customizable Actions: Attach your own logic (logging, Slack, Webhooks) when alerts trigger.
  • Built-in Emailing: Seamlessly send Gmail alerts to you and your team (single or multiple CC supported).
  • Clear Reports: Beautifully structured WHERE–WHAT–WHEN formats.
  • Safe & Minimal: Zero impact on your app's performance and minimal dependencies.

Installation

npm install express-watchdog

Basic Usage

Getting started is as simple as adding a few lines to your Express app:

const express = require("express");
const monitor = require("express-watchdog");

const app = express();

monitor(app, {
  slowThresholdMs: 2000,
  alertEmail: process.env.ALERT_EMAIL,
  ccEmail: ["[email protected]", "[email protected]"], // Single string or array of strings
  appPassword: process.env.EMAIL_APP_PASSWORD
});

app.listen(3000);

Custom Functions (Powerful & Flexible!)

Want to send alerts to Slack, log to a database, or trigger a webhook? You can easily attach your own handlers!

When you provide onSlow or onCrash, express-watchdog will call your function instead of sending the default email.

monitor(app, {
  slowThresholdMs: 2000,
  // Your custom logic here!
  onSlow: async ({ where, what, when, path, duration }) => {
    console.log(`Slow API detected at ${path}! Took ${duration}ms.`);
    // Add your Slack integration or database logging here
  },
  onCrash: async ({ where, what, when, message, stack }) => {
    console.error(`Critical Error: ${message}`);
    // Handle the crash gracefully or notify your dev team
  }
});

Email Configuration (Optional)

If you don't provide custom handlers, the watchdog defaults to sending emails via Gmail.

Recommended Environment Variables:

[email protected]
[email protected]
EMAIL_APP_PASSWORD=your-app-password

How It Works

  1. Performance Tracking: Wraps Express requests to measure exactly how long they take.
  2. Process Monitoring: Hooks into uncaughtException and unhandledRejection.
  3. Smart Alerting: Triggers your custom functions or sends a detailed email with full context.

License

ISC