Beignet API reference
    Preparing search index...

    Interface RateLimitOptions<Ctx>

    Options for createRateLimitHooks(...).

    interface RateLimitOptions<Ctx> {
        earlyKey?: (
            args: { req: HttpRequestLike; scope: EarlyRateLimitScope },
        ) => string;
        getClientIp?: (req: HttpRequestLike) => string | undefined;
        key?: (
            args: { ctx: Ctx; req: HttpRequestLike; scope: RateLimitScope },
        ) => string;
    }

    Type Parameters

    • Ctx
    Index

    Properties

    earlyKey?: (
        args: { req: HttpRequestLike; scope: EarlyRateLimitScope },
    ) => string

    Build a rate-limit key before request parsing and context creation.

    This is used for global and IP-scoped limits.

    getClientIp?: (req: HttpRequestLike) => string | undefined

    Resolve a client IP from the raw request.

    key?: (
        args: { ctx: Ctx; req: HttpRequestLike; scope: RateLimitScope },
    ) => string

    Build a rate-limit key after context exists.

    This is used for user-scoped limits and any late key strategy.