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-slack-stats

v1.1.1

Published

Express middleware to send API stats and exit codes to Slack

Downloads

26

Readme

express-slack-stats

npm version npm downloads TypeScript License: MIT Build Status

📊 Express middleware to send API request stats and process exit alerts to Slack. Supports endpoint stats, status codes, latency averages, and exit code notifications — all delivered as clean Slack Block Kit messages.


✨ Features

  • Tracks:

    • Hits per endpoint (with param normalization, e.g. /users/123/users/_)
    • Methods (GET, POST, etc.)
    • Status codes (200, 404, 500, …)
    • Average response time
  • Aggregates stats into periodic Slack reports (configurable with cron syntax)

  • Reports Node.js process exit codes and uncaught errors

  • Lightweight & simple to drop into any Express app

  • Written in TypeScript with full type definitions


📦 Installation

npm install express-slack-stats

or

yarn add express-slack-stats

🚀 Usage

import express from "express";
import expressSlackStats from "express-slack-stats";

const app = express();

expressSlackStats(app, {
  webhookUrl: process.env.SLACK_WEBHOOK as string, // required
  schedule: "*/10 * * * *", // optional, default: every 5 min
  includeExitCodes: true,    // optional, default: true
  sendEmptyReports: false,   // optional, default: false
  includeCharts: true,       // optional, default: false
});

app.get("/users/:id/profile", (req, res) => {
  res.json({ ok: true });
});

app.listen(3000, () => console.log("Server running"));

⚙️ Options

| Option | Type | Default | Description | | ------------------ | --------- | --------------- | --------------------------------------------------------------------------- | | webhookUrl | string | required | Slack Incoming Webhook URL | | schedule | string | "*/5 * * * *" | Cron syntax for how often to send stats (e.g. "*/10 * * * *" = every 10m) | | includeExitCodes | boolean | true | Whether to report process exit codes and crashes to Slack | | sendEmptyReports | boolean | false | Whether to send reports when no API activity was recorded | | includeCharts | boolean | false | Whether to include ASCII charts in the Slack reports |


📊 Example Slack Report

Basic Table Format:

📊 API Stats Report

Endpoint                    | Hits | Status       | Avg Time
----------------------------|------|--------------|----------
GET /api/users/:id          |   25 | 200:20,404:5 | 145.2ms
POST /api/users             |   12 | 201:10,400:2 | 89.7ms
GET /api/products/:id       |    8 | 200:8        | 67.3ms
POST /api/login             |   12 | 200:11,401:1 |  89.5ms

With Charts (when includeCharts: true):

📊 API Stats Report

Endpoint                    | Hits | Status       | Avg Time
----------------------------|------|--------------|----------
GET /api/users/:id          |   45 | 200:44,500:1 | 120.3ms
POST /api/login             |   12 | 200:11,401:1 |  89.5ms

API Endpoint Hit Distribution:

GET /api/users/:id        │████████████████████ 45
POST /api/login           │█████████ 12
GET /api/products         │███ 5

Status Code Distribution:

200 OK           │■■■■■■■■■■■■■■■ 50 (80.6%)
401 Unauthorized │■■ 8 (12.9%)
500 Server Error │■ 4 (6.5%)

(Delivered as a Slack Block message with header, table, optional charts, and timestamp.)