Registry / security / web-gatekeeper-js

web-gatekeeper-js

JSON →
library1.2.6jsnpmunverified

Redis-based rate limiter and throttler for Node.js using sliding window and token bucket algorithms. v1.2.6 is current stable, with active maintenance (last update recent). Designed for distributed/horizontally scaled environments (Kubernetes, load-balanced servers). Uses atomic Lua scripts to prevent race conditions. Supports Express, Fastify, NestJS, Koa. Alternative to express-rate-limit but Redis-backed for multi-instance consistency. Lightweight, TypeScript support, requires ioredis peer dependency.

npm install web-gatekeeper-js
INSTALL
IMPORT
SIG · WEB-GATEKEEPER-JS
W
web-gatekeeper-js
securityjavascriptv1.2.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RateLimiter
import { RateLimiter } from 'gatekeeper-js'
import RateLimiter from 'gatekeeper-js'
Named export, not default. Package is ESM-only.
Throttler
import { Throttler } from 'gatekeeper-js'
const { Throttler } = require('gatekeeper-js')
Package is ESM-only; no CommonJS support. Use dynamic import() if needed in CJS context.
RateLimiterOptions
import type { RateLimiterOptions } from 'gatekeeper-js'
TypeScript type import for configuration object.

Basic Express rate limiting middleware using sliding window algorithm with Redis.

import { RateLimiter } from 'gatekeeper-js'; import Redis from 'ioredis'; const redis = new Redis(); const limiter = new RateLimiter({ redisClient: redis, windowSize: 60000, limit: 100, maxToken: 10, refillRate: 2 }); // Express middleware example app.use(async (req, res, next) => { const result = await limiter.consume(req.ip); if (!result.allowed) { return res.status(429).json({ error: result.reason }); } next(); });
Debug
Known issues
gotchaPackage must be installed as 'gatekeeper-js' not 'web-gatekeeper-js'. npm package name mismatch with repo name.
fix
npm install gatekeeper-js ioredis
affects: >=1.0.0
breakingMissing ioredis peer dependency will cause runtime error on initialization.
fix
Ensure ioredis v5.10+ is installed: npm install ioredis
affects: >=1.0.0
gotchaRateLimiterOptions fields 'windowSize' and 'limit' are required but not validated; passing string instead of number fails silently.
fix
Always pass numeric values for windowSize (ms) and limit (count).
affects: >=1.0.0
gotchaconsume() returns { allowed: boolean, reason?: string }. Do not compare result.allowed === true; use truthiness.
fix
Check `if (!result.allowed)` not `if (result.allowed === false)`.
affects: >=1.0.0
gotchaThrottler's maxWait option in milliseconds; misinterpreting as seconds leads to unexpected delays.
fix
Set maxWait in milliseconds (e.g., 5000 for 5 seconds).
affects: >=1.0.0
deprecatedImport path 'gatekeeper-js' may be renamed to 'web-gatekeeper-js' in future releases.
fix
Stay tuned for v2 announcement; currently use 'gatekeeper-js'.
affects: =1.2.6
Errors
Common errors & fixes
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'gatekeeper-js' imported from ...
npm package name is 'gatekeeper-js', not 'web-gatekeeper-js'.
fix
Install as: npm install gatekeeper-js
TypeError: limiter.consume is not a function
Using default import instead of named import.
fix
Use: import { RateLimiter } from 'gatekeeper-js'
ReferenceError: Redis is not defined
ioredis not installed or not imported.
fix
npm install ioredis && import Redis from 'ioredis'
Error: Lua script error: ERR wrong number of arguments for 'eval' command
Redis connection failure or misconfigured client.
fix
Ensure Redis is running and connection string is correct.
TypeError: Cannot read properties of undefined (reading 'allowed')
consume() returned undefined due to promise rejection not caught.
fix
Use try/catch around await limiter.consume() or add .catch().
Upgrade
Version history
1.2.6latest on npm
Audit
Dependencies
ioredisrequiredRedis client for all operations
Agent activity
31 hits · last 30 days
node
26
OpenAI (training)
1
Resources
web-gatekeeper-js — npm install web-gatekeeper-js · libregistry