Stone.js API
    Preparing search index...

    A limiter: something that counts hits against a key and says whether one may proceed.

    The limit is passed in rather than held by the limiter, deliberately. An implementation that can refuse atomically, through a conditional write, has to know the limit to express the condition, and refusing without writing is what stops a flood from costing one write per rejected request. A limiter that increments and then compares pays for every refusal and lets the counter climb without bound inside the window.

    interface RateLimiter {
        hit: (
            key: string,
            limit: number,
            windowMs: number,
        ) => Promise<RateLimitHit>;
    }

    Implemented by

    Index
    hit: (key: string, limit: number, windowMs: number) => Promise<RateLimitHit>

    Count one hit against key and say whether it may proceed.

    Type Declaration

      • (key: string, limit: number, windowMs: number): Promise<RateLimitHit>
      • Parameters

        • key: string

          What the budget belongs to.

        • limit: number

          How many hits the window allows.

        • windowMs: number

          How long the window lasts.

        Returns Promise<RateLimitHit>