@pwngh/economy-lab
    Preparing search index...

    Function memoryRateLimiter

    • Builds an in-process RateLimiter counting fixed windows in a Map. It exposes the same observable contract as the Redis adapter and serves as a usable single-process limiter when no Redis is wired.

      Each key gets limit requests per windowMs, measured against the injected clock; a denial reports how long until the window resets. An expired window is replaced only when its key is next seen, so the map retains every key it has ever counted.

      Parameters

      • options: { limit: number; windowMs: number }
      • clock: Clock = ...

      Returns RateLimiter

      const limiter = memoryRateLimiter({ limit: 100, windowMs: 60_000 });
      await limiter.allow('user:usr_42'); // { allowed: true }

      HTTP service for how the server keys and answers denials.