Beignet API reference
    Preparing search index...

    Rate limit configuration for a contract.

    This type is used in contract metadata to configure rate limiting behavior.

    const getTodoContract = c
    .get("/api/todos/:id", "getTodo")
    .pathParams(z.object({ id: z.string() }))
    .meta({
    auth: "required",
    rateLimit: {
    max: 60,
    windowSec: 60,
    scope: "user",
    },
    })
    .responses({ 200: z.object({ id: z.string(), name: z.string() }) });
    interface RateLimitMeta {
        max: number;
        scope?: RateLimitScope;
        windowSec: number;
    }
    Index

    Properties

    Properties

    max: number

    Maximum number of allowed hits within the window.

    Scope for identifying the rate limit key.

    • "user": keyed by authenticated user id
    • "ip": keyed by client IP
    • "global": single global key

    Default: "global".

    windowSec: number

    Length of the window in seconds.