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

@spinejs/throttle

v0.1.5

Published

Rate-limiting battery for SpineJS: exact sliding-window policies enforced as a gateway interceptor, transport-blind core with HTTP and electron-ipc presets.

Readme

@spinejs/throttle

Rate limiting for SpineJS gateways: declare named policies, place one interceptor, get exact sliding-window 429s with Retry-After and RateLimit-* headers — off by default, zero overhead when unconfigured.

// src/main.ts
import { ThrottleModule, throttleInterceptorRef } from "@spinejs/throttle";
import type { ThrottleInterceptor } from "@spinejs/throttle";
import { throttleHttp } from "@spinejs/throttle/http";
import { HttpGatewayModule } from "@spinejs/http-gateway";

HttpGatewayModule.configure({
  imports: [
    ThrottleModule.configure({
      policies: {
        global: { limit: 100, windowMs: 60_000, keyBy: "ip", scope: "gateway" },
      },
      // Wires the `'ip'` key source AND turns on `RateLimit-*` + `Retry-After` headers (on by
      // default; pass `{ headers: false }` to disable). Presentation lives on `./http`.
      ...throttleHttp(),
    }),
  ],
  interceptors: {
    inject: [throttleInterceptorRef()],
    // First = outermost: rejected requests consume no guard/validation/handler work.
    factory: (throttle: ThrottleInterceptor) => [throttle],
  },
  // ...contextFactory, port
});

A policy is a plain object: { limit, windowMs, keyBy } — at most limit accepted hits per key inside a sliding windowMs window, exactly (sliding-window log, no approximation). keyBy names a wired key source ('ip' from @spinejs/throttle/http, 'sender' from @spinejs/throttle/electron-ipc, 'identity' wired by your app) or is a custom (ctx, rawInput) => string | null selector.

Full guides (route options, custom keys, the store port, IPC error mapping) live in the SpineJS documentation site.

Validate route-inline specs at boot

To fail startup (not the first dispatch) on a bad route-inline throttle spec, place throttleMetaValidatorRef() in the gateway's metaValidators — the framework MetaValidator slot — next to the interceptor:

metaValidators: {
  inject: [throttleMetaValidatorRef()],
  factory: (v) => [v],
},

The gateway crosses its own routes against its own validators at start, so validated routes == enforced routes (a validator can't be wired to the wrong gateway).

Migrating from 0.1.4 (breaking). ThrottleModule.configure({ routes }) and the RouteSnapshot/RouteSnapshotSource exports were removed. Replace ThrottleModule.configure({ routes: { inject: [HttpGateway], factory: (gw) => () => gw.routes } }) with the metaValidators: [throttleMetaValidatorRef()] wiring above on the gateway. Runtime enforcement (the interceptors wiring) is unchanged.

Subpath exports

| Import | Contents | | -------------------------------- | ----------------------------------------------------------------- | | @spinejs/throttle | policy types, module, interceptor, store/clock ports, outcome ctx | | @spinejs/throttle/http | 'ip' key source + RateLimit-*/Retry-After header translator | | @spinejs/throttle/electron-ipc | 'sender' key source | | @spinejs/throttle/testing | store contract kit for custom store implementations |