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

@tumull/shield

v1.2.0

Published

Drop-in API rate limiting & DDoS protection for Node.js/Next.js

Readme

@tumull/shield

Rate limiting, bot detection, and brute force protection for Node.js apps. Works with Next.js, Express, Fastify, Hono, or plain http. No external dependencies in the core.

npm downloads bundle license tests release


Why?

Most rate limiting libs are either too simple (fixed window, no bot detection) or tied to a paid service. Shield gives you sliding window, token bucket, bot detection, brute force protection, and per-route config — all in one package, for free, with zero lock-in.

Install

npm install @tumull/shield

Usage

Next.js

// middleware.ts
import { shield } from '@tumull/shield'

export default shield({
  limit: 100,
  window: '1m',
})

export const config = {
  matcher: '/api/:path*',
}

That's basically it. Your API routes are rate-limited now.

Express

import express from 'express'
import { shieldExpress } from '@tumull/shield'

const app = express()
app.use(shieldExpress({ limit: 100, window: '1m' }))

Fastify

import Fastify from 'fastify'
import { shieldFastify } from '@tumull/shield'

const app = Fastify()
app.register(shieldFastify, { limit: 100, window: '1m' })

Hono

import { Hono } from 'hono'
import { shieldHono } from '@tumull/shield'

const app = new Hono()
app.use('*', shieldHono({ limit: 100, window: '1m' }))

Node.js HTTP

import http from 'node:http'
import { shieldNode } from '@tumull/shield'

const limiter = shieldNode({ limit: 100, window: '1m' })

http
  .createServer(async (req, res) => {
    if (await limiter(req, res)) return // blocked
    res.writeHead(200)
    res.end('ok')
  })
  .listen(3000)

Config

shield({
  limit: 100, // requests per window
  window: '1m', // "30s", "1m", "5m", "1h", "1d"
  block: '15m', // how long to block after exceeding limit
  algorithm: 'sliding-window', // or 'fixed-window', 'token-bucket'

  // different limits for different routes
  routes: {
    '/api/auth/login': { limit: 5, window: '5m', block: '30m' },
    '/api/public/*': { limit: 500, window: '1m' },
    '/api/private/*': { allowlistGeo: ['US', 'CA'] },
    '/api/webhook/*': { skip: true },
  },

  // custom key (default: client IP)
  key: (req) => req.headers.get('x-api-key') ?? extractIP(req),

  store: 'memory', // default. also supports Redis, Upstash
  botDetection: true,
  blockBots: ['scrapy', 'curl'],
  allowlist: ['127.0.0.1'],
  // country-level controls (ISO codes)
  allowlistGeo: ['US', 'CA'],
  blocklistGeo: ['RU'],
  wafEnabled: true,
  wafRules: [
    { target: 'query', operator: 'regex', value: 'union\\s*select', flags: 'i' },
    { target: 'path', value: '/admin' },
  ],
  blocklist: [],
  headers: true, // X-RateLimit-* headers

  onLimit: (req, retryAfter) =>
    new Response(JSON.stringify({ error: 'Slow down' }), { status: 429 }),
})

Full config reference → docs/configuration.md

Stores

Memory (default) — no setup, works everywhere. LRU eviction keeps memory bounded.

import { shield, MemoryStore } from '@tumull/shield'
shield({ store: new MemoryStore({ maxSize: 10_000 }) })

Redis — for multi-instance / production setups.

import { RedisStore } from '@tumull/shield/stores/redis'
import Redis from 'ioredis'

shield({ store: new RedisStore({ client: new Redis(process.env.REDIS_URL) }) })

Upstash — HTTP-based, works on the edge (Vercel Edge, Cloudflare Workers).

import { UpstashStore } from '@tumull/shield/stores/upstash'

shield({
  store: new UpstashStore({
    url: process.env.UPSTASH_REDIS_URL!,
    token: process.env.UPSTASH_REDIS_TOKEN!,
  }),
})

More details → docs/stores.md

Algorithms

| Algorithm | What it does | Good for | | ---------------- | --------------------------------------------- | ------------------- | | sliding-window | Weighted average of current + previous window | Most apps (default) | | fixed-window | Simple counter, resets on interval | High throughput | | token-bucket | Tokens refill at constant rate | Bursty traffic |

More details → docs/algorithms.md

Response headers

When headers: true (default):

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 73
X-RateLimit-Reset: 1708934400

When blocked → 429 Too Many Requests with Retry-After header.

How it compares

| | Shield | express-rate-limit | @upstash/ratelimit | Arcjet | | ------------------ | ------ | ------------------ | ------------------ | -------- | | Next.js middleware | ✅ | ❌ | ✅ | ✅ | | Edge runtime | ✅ | ❌ | ✅ | ✅ | | Zero deps | ✅ | ✅ | ❌ | ❌ | | Sliding window | ✅ | ❌ | ✅ | ✅ | | Bot detection | ✅ | ❌ | ❌ | ✅ | | Brute force | ✅ | ❌ | ❌ | ✅ | | Per-route config | ✅ | manual | ❌ | ✅ | | Free | ✅ | ✅ | freemium | freemium |

Docs

Contributing

See CONTRIBUTING.md.

License

MIT — TUMULL I.N.C.