upstash / ratelimit-js

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

Add Reset Field to `getRemaining` #113

Closed CahidArda closed 4 months ago

CahidArda commented 4 months ago

With this change, we update the getRemaining method like:

-  public getRemaining = async (identifier: string): Promise<number> => {
+  public getRemaining = async (identifier: string): Promise<{
+    remaining: number;
+    reset: number;
+  }> => {

We essentially update the returned object from a number to a dictionary with remaining and reset time information.

Number of commands executed doesn't change.

Addresses #111

linear[bot] commented 4 months ago

DX-989 Add get reset time method to ratelimit

vercel[bot] commented 4 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ratelimit-with-vercel-kv ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2024 1:52pm
fahreddinozcan commented 4 months ago

Also, we can add some comments related to reset being a timestamp in the code, which would make it easier to reason

CahidArda commented 4 months ago

added packageManager to kv-with-vercel example package.json to resolve this issue