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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@inspectr/express

v0.0.2

Published

Inspectr Express middleware to capture and inspect HTTP requests/responses with a built-in Inspectr UI.

Downloads

5

Readme

Inspectr for Express

Inspectr is a NPM package that provides middleware for Express applications to capture and inspect every incoming request and outgoing response. It also includes a built‑in Inspectr UI (accessible at http://localhost:4004) where you can view request & response details in real time.

Features

  • Express Middleware: Intercepts HTTP requests and responses and webhooks.
  • Real-time Inspector: Inspect Requests & Responses in the Inspectr App.
  • Log Requests: Log request data to the console.
  • Easy Integration: Simply add the middleware to your Express app.

Installation

Install the package via npm:

npm install @inspectr/express

Usage

  1. Integrate the Inspectr Middleware into Your Express Application

In your Express application, require the package and use the middleware. For example:

// app.js
const express = require('express');
const inspectr = require('@inspectr/express');

const app = express();

// (Optional)Set the broadcast URL for Inspectr.
// inspectr.setBroadcastUrl('http://localhost:4004/sse');

// Add the inspectr middleware BEFORE your routes
app.use(inspectr.capture);

// Define your routes
app.get('/', (req, res) => {
 res.send('Hello, world!');
});

// Start your Express server as usual
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
 console.log(`Express app listening on port ${PORT}`);
});
  1. Configuration Options

The capture() function accepts an optional configuration object to control how request and response data is handled:

| Option | Type | Default | Description | |:------------|:--------|:--------|:-------------------------------------------------------------------------------------------| | broadcast | boolean | true | If true, sends request/response data to the SSE for real-time viewing in the Inspectr App. | | print | boolean | true | If true, logs request/response details to the console in a structured format. |

Examples Enable only console logging (disable SSE broadcasting):

app.use((req, res, next) => {
  inspectr.capture(req, res, next, { broadcast: false, print: true });
});

Enable only SSE broadcasting (disable console logging):

app.use((req, res, next) => {
  inspectr.capture(req, res, next, { broadcast: true, print: false });
});

Or access the data directly

// Add the inspectr middleware BEFORE your routes
app.use((req, res, next) => {
  inspectr(req, res, next, { broadcast: true, print: true })
    .then(data => {
      // Optionally, process the captured data (e.g., log it)
      console.log('Captured data:', data);
    })
    .catch(err => {
      console.error('Inspectr error:', err);
      next(err);
    });
});

Use default behavior (both enabled):

app.use(inspectr.capture);
  1. Run the Inspectr App

The Inspectr App is provided as a separate command-line tool that serves the App on port 4004. Once your app is running ( and using the middleware), you can start the Inspectr App in another terminal:

If you installed the package locally:

  @inspectr/express

or as package.json script

"scripts": {
 "inspectr-app": "inspectr"
}

Then open your browser to http://localhost:4004 to view the inspectr interface.