Serverless ratelimiting
@unkey/ratelimit
is a library for fast global ratelimiting in serverless functions.
timeout
config in the constructor (see below).
The SDK captures most errors and handles them on its own, but we also encourage you to add a onError
handler to configure what happens in case something goes wrong.
Both fallback
property of the timeout
config and onError
config are callback functions. They receive the original request identifier as one of their parameters, which you can use to determine whether to reject the request.
new Ratelimit(config: RatelimitConfig)
.limit(identifier: string, opts: LimitOptions): Promise<RatelimitResponse>
RatelimitResponse