upstash / ratelimit-js

Rate limiting library for serverless runtimes
https://ratelimit-with-upstash.vercel.app/
MIT License
1.75k stars 34 forks source link

Dynamic token cost on Ratelimit.tokenBucket algorithm #58

Closed norberto-e-888 closed 11 months ago

norberto-e-888 commented 1 year ago

Is there a way to dynamically calculate how many tokens a request should cost?

chronark commented 1 year ago

Check this script: https://github.com/upstash/ratelimit/blob/c509628a6c1490121d810822ce7c880ddb02c44c/packages/sdk/src/single.ts#L284

It's either 3 or 4, depending on whether the bucket exists and its state

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] commented 11 months ago

This issue was closed because it has been stalled for 30 days with no activity.