Closed AlessandroGasparri closed 2 months ago
Hey, could you add a code snippet of an example how you'd like to use this?
Hi, thank you for your response and sorry for the delay, i missed the email. I was thinking something like:
new Ratelimit({
limit: 5,
duration: '1d',
namespace: 'namespace',
rootKey: process.env.UNKEY_ROOT_KEY!,
timeout: {
ms: 3000,
fallback: (resourceIdentifier) => {
// Additional logic here with resourceIdentifier
return { success: true, limit: 0, remaining: 0, reset: 0 }
}
},
onError: (resourceIdentifier, error) => {
// Additional logic here with resourceIdentifier and error
return { success: true, limit: 0, remaining: 0, reset: 0 }
}
})
Thank you, that makes it clearer.
Sounds like a great idea, would you want to tackle this one?
Sure! I'll provide a PR and link it to this issue once I have it ready
Hi! Sorry for the delay, I have been busy at work. I've opened the PR #1998.
Hi, thank you for approving the pull request! We need these changes in our codebase. Could you please let me know the expected timeframe for the release to be published on npm?
@AlessandroGasparri today, I'll ping you
@AlessandroGasparri v0.4.0 is released
Preliminary Checks
[X] I have reviewed https://unkey.com/docs for existing features that would solve my problem
[X] I have searched for existing feature requests: https://github.com/unkeyed/unkey/issues
[X] This issue is not a question, general help request, or anything other than a feature request directly related to Unkey. Please ask questions in our Discord community: https://unkey.com/discord.
Is your feature request related to a problem? Please describe.
Currently, when using the ratelimit SDK, the behavior upon hitting an error is to either:
I would like to dynamically handle this scenarios to implement another mechanism of rate limiting in case something is wrong with the network or with the request.
Describe the solution
The solution I've come up with is pretty simple:
Describe alternatives you have considered (if any)
No response
Additional context
No response