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

@ceptesoft/rate-limit-groups

v0.1.0

Published

Declarative path-group rate limiting with a pluggable store and a documented fail-open contract — rate limiting must never take your app down. Zero dependencies.

Readme

@ceptesoft/rate-limit-groups

Declarative path-group rate limiting with a pluggable store and a documented fail-open contract. Zero dependencies.

Extracted from production middleware (CepteCari), where auth endpoints get 10 req/60s and general API paths 60 req/60s — and where the deliberate security decision was: if the rate-limit store is down, let traffic through. Failing closed would turn a store outage into a self-inflicted denial of service on every guarded path. Rate limiting is defense-in-depth; availability wins.

Scope boundary: no HTTP framework types — you pass a pathname and a client key (IP, user id). Adapters for Next.js/Express are one-liners at the call site.

Install

npm install @ceptesoft/rate-limit-groups

Quickstart

import {
  createRateLimiter,
  createMemoryStore,
  prefixMatcher,
} from "@ceptesoft/rate-limit-groups";

const limiter = createRateLimiter({
  store: createMemoryStore(), // or your Redis-backed store (below), or null to disable
  groups: [
    { name: "auth", match: prefixMatcher(["/login", "/signup"]), limit: 10, windowSeconds: 60 },
    { name: "api", match: prefixMatcher(["/api/"]), limit: 60, windowSeconds: 60 },
  ],
});

// Middleware (IP-based)
const { limited, retryAfter } = await limiter.checkPath(pathname, clientIp);
if (limited) return new Response("Too Many Requests", {
  status: 429,
  headers: { "Retry-After": String(retryAfter) },
});

// Server Action (user-based, direct group)
const decision = await limiter.check("auth", userId);

The store interface

type RateLimitStore = {
  limit(key: string, limit: number, windowMs: number): Promise<{ success: boolean; reset: number }>;
};

createMemoryStore() ships in the box: an accurate sliding-window log, but instance-local — right for tests and single-node servers, wrong for serverless fleets. For distributed limiting back it with Redis; an Upstash adapter is this small (with @upstash/ratelimit and @upstash/redis installed in your app):

import { Ratelimit } from "@upstash/ratelimit";
import { Redis } from "@upstash/redis";
import type { RateLimitStore } from "@ceptesoft/rate-limit-groups";

function upstashStore(redis: Redis): RateLimitStore {
  const limiters = new Map<string, Ratelimit>();
  return {
    async limit(key, limit, windowMs) {
      const id = `${limit}:${windowMs}`;
      let rl = limiters.get(id);
      if (!rl) {
        rl = new Ratelimit({
          redis,
          limiter: Ratelimit.slidingWindow(limit, `${windowMs / 1000} s`),
          prefix: "rl",
          ephemeralCache: new Map(),
        });
        limiters.set(id, rl);
      }
      const r = await rl.limit(key);
      return { success: r.success, reset: r.reset };
    },
  };
}

// Config arrives as parameters — this package never reads process.env
const store = url && token ? upstashStore(new Redis({ url, token })) : null;

Fail-open semantics (by design)

{ limited: false } is returned when: the path matches no group, store is null, or the store rejects/throws. Programmer errors still throw: duplicate group names, non-positive limits, check() with an unknown group name.

API

  • createRateLimiter({ store, groups, now? }){ checkPath, check }. Group: { name, match, limit, windowSeconds, keySegment? }. Buckets are keyed <group>:<clientKey>:<segment>, where segment defaults to the first two path segments (per-endpoint buckets inside a group).
  • prefixMatcher(prefixes)match function.
  • createMemoryStore({ now? }) → in-memory sliding-window RateLimitStore.