upstash / ratelimit-js

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

How to set one hour limit for sliding window? #85

Closed samuelpalaciosdev closed 8 months ago

samuelpalaciosdev commented 8 months ago

Hey, I've been trying to setup my rate limiter like this: const ratelimit = new Ratelimit({ redis: Redis.fromEnv(), limiter: Ratelimit.slidingWindow(2, '3600 s'), }); But it doesn't seem to work, there's a special way to reference an hour or theres a time limit?

fahreddinozcan commented 8 months ago

Hey, can you try slidingWindow(2, "1 h")? The possible units are ms | s | m | h | d |

samuelpalaciosdev commented 8 months ago

Thanks! didn't know that. It could be a good add to the documentation.