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

@bhargavanaidupola/security-inspector

v0.1.0

Published

Reusable API security inspection middleware for Node backends.

Readme

Security Inspector

Reusable Express middleware for capturing request security events.

This folder is structured like a package so it can later be moved to its own npm package. The middleware does not depend on Prisma, a dashboard, or this app's routes. It emits a SecurityEvent and saves it through a storage adapter.

Install

npm install @bhargavanaidupola/security-inspector

Express Usage

When using the published npm package, import from @bhargavanaidupola/security-inspector. When using this folder locally, import from ./security-inspector.

import express from "express";
import {
  ConsoleSecurityAlertHandler,
  ConsoleSecurityEventStorage,
  commonAttackPatternsDetector,
  createExpressSecurityMiddleware,
  repeatedRequestsDetector,
  suspiciousKeywordsDetector,
} from "./security-inspector";

const app = express();
app.use(express.json({ limit: "100kb" }));

app.use(createExpressSecurityMiddleware({
  appName: "my-website",
  mode: "monitor",
  storage: new ConsoleSecurityEventStorage(),
  skipPaths: ["/health", "/metrics"],
  captureBody: false,
  maskHeaders: ["authorization", "cookie", "x-api-key"],
  maskBodyFields: ["password", "token", "otp"],
  blockThreshold: 80,
  alertThreshold: 80,
  alertHandlers: [new ConsoleSecurityAlertHandler()],
  detectors: [
    suspiciousKeywordsDetector(),
    commonAttackPatternsDetector(),
    repeatedRequestsDetector(),
  ],
}));

Modes

  • monitor: log events and allow requests.
  • block: log events and return 403 when risk is at or above blockThreshold.
  • off: skip all inspection.

Storage

Implement SecurityEventStorage for any backend:

  • Prisma
  • MongoDB
  • PostgreSQL
  • HTTP collector
  • Console logs
  • Memory storage for tests

The current app uses a Prisma-backed adapter in src/middleware/interceptor.ts.

Included Storage Adapters

import {
  ConsoleSecurityEventStorage,
  HttpCollectorStorage,
  MemorySecurityEventStorage,
  PrismaSecurityEventStorage,
} from "./security-inspector";

const consoleStorage = new ConsoleSecurityEventStorage();

const httpStorage = new HttpCollectorStorage({
  endpoint: "https://collector.example.com/events",
  apiKey: process.env.INSPECTOR_API_KEY,
});

const prismaStorage = new PrismaSecurityEventStorage({
  requestDelegate: prisma.request,
});

Alerts

Alerts run when riskScore >= alertThreshold.

import {
  ConsoleSecurityAlertHandler,
  WebhookAlertHandler,
} from "./security-inspector";

alertHandlers: [
  new ConsoleSecurityAlertHandler(),
  new WebhookAlertHandler({
    endpoint: "https://alerts.example.com/security",
    apiKey: process.env.SECURITY_ALERT_KEY,
  }),
]

Package Build

This folder includes package.json and tsconfig.json, so it can be copied into its own repository and built:

npm install
npm run build

Later, publish it as:

npm publish --access public