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

botnot

v1.0.0

Published

An Express/Next.js compatible package to detect and block bots using User-Agent inspection, rate limiting, and configurable allow/deny lists.

Readme

🛡️ botnot

botnot is a lightweight and pluggable Node.js module to detect and block bots using User-Agent fingerprinting, rate limiting, and flexible allow/deny lists.
It’s perfect for securing APIs, login pages, contact forms, and public routes in Express, Next.js, or even vanilla Node.js servers.

npm license issues


✨ Features

  • 🧠 Detects bots via User-Agent fingerprinting
  • 🔐 Allow or deny specific IPs and User-Agents
  • 📈 Built-in rate limiting per IP + User-Agent
  • ⚙️ Easy to plug into Express, Next.js, or custom Node.js servers
  • 🧾 TypeScript support with full typings
  • 🧰 Zero dependencies – lightweight & fast

📦 Installation

npm install botnot

⚙️ Configuration Options

| Option | Type | Description | |-----------------|------------------------------|-------------| | allowlistIPs | string[] | IPs to always allow | | denylistIPs | string[] | IPs to always block | | allowlistUAs | string[] | Substrings of UAs to allow | | denylistUAs | string[] | Substrings of UAs to block | | rateLimit | { windowMs, maxRequests } | Rate limiting configuration | | log | boolean | Enable console logging (default: false) |


🚀 Usage Examples

✅ 1. Express (Node.js) Example

import express from 'express';
import { botDetector } from 'botnot';

const app = express();

app.use(botDetector({
  log: true,
  rateLimit: {
    windowMs: 60000,
    maxRequests: 30,
  },
  denylistUAs: ['curl', 'python', 'wget']
}));

app.get('/', (req, res) => {
  res.send('You are human ✅');
});

app.listen(3000, () => console.log('Running on http://localhost:3000'));

✅ 2. Next.js API Route Example

// pages/api/protected.ts
import type { NextApiRequest, NextApiResponse } from 'next';
import { botDetector } from 'botnot';
import { NextApiHandler } from 'next';

const withBotProtection = (handler: NextApiHandler) => {
  const middleware = botDetector({ log: true });

  return async (req: NextApiRequest, res: NextApiResponse) => {
    await new Promise<void>((resolve, reject) => {
      middleware(req as any, res as any, (err?: any) => {
        if (err) reject(err);
        else resolve();
      });
    });

    return handler(req, res);
  };
};

const handler: NextApiHandler = async (req, res) => {
  res.status(200).json({ message: 'You are not a bot ✅' });
};

export default withBotProtection(handler);

✅ 3. Raw Node.js HTTP Server Example

import http from 'http';
import { botDetector } from 'botnot';

const detector = botDetector({ log: true });

const server = http.createServer((req, res) => {
  detector(req as any, res as any, (err?: any) => {
    if (err) return;
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Human access granted ✅');
  });
});

server.listen(3000, () => {
  console.log('Raw HTTP server running on http://localhost:3000');
});

🧩 Use Cases

  • 🔐 Stop brute-force attacks on login or admin endpoints
  • 🤖 Prevent scrapers from abusing your public APIs
  • 📄 Protect form submissions from bots and spam
  • ⚡ Reduce server load by dropping suspicious traffic early

🛠 Roadmap

  • [ ] Redis-based rate limiting for distributed deployments
  • [ ] Request fingerprinting (header behavior, IP analysis)
  • [ ] Bot scoring engine (UA + behavior)
  • [ ] CLI tool for log analysis
  • [ ] Admin dashboard or visual stats

📝 License

MIT © Vishal Kumar Sharma


🤝 Contributing

We welcome contributions, ideas, and feedback!

  • 📥 Submit issues or bug reports in GitHub Issues
  • 🧑‍💻 Fork, build, and open a PR with improvements