-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Todo #1
Comments
It's published! https://www.npmjs.com/package/ratelimit-header-parser |
I'm also thinking about renaming the public API:
Additionally, I'm thinking about Policy headers. In general, we could add policy info onto the RateLimit object, but it's possible to have a policy without the associated remaining or reset values, so what then? Maybe omit them from |
Maybe this could be
Could you please give me an example of when multiple rate limit headers could be returned?
Maybe we can export these functions as parsers? Each type of ratelimit headers gets its own About the policy headers - should we make that a separate method, like |
Also, should we add a |
Multiple rate limits example: User & Client limits: https://apidocs.imgur.com/ In general, I'd like to match the policy to the RateLimit and include all the details in a single object. However, the IETF draft had had a few examples with multiple policies but only one RateLimit header, which is the scenario I'm thinking about how to handle. As for testing the examples, that sounds like a good idea, at least to ensure they don't throw. Validating the results might be a bit harder without making the examples themselves more tricky |
Oh I see what you mean. I think we should do the following:
I don't see the need to validate the results per se, we're already doing that in the tests. Just a no-throw is what I implemented in 9e6a84b, does that seem good? |
I feel like the normal case is going to be only retrieving a single rate limit, which is why I was thinking of differentiating between the singular and plural functions. The singular one can also be a bit better optimized, because it can stop as soon as it finds a single match, whereas a plural version would have to do an exhaustive search each time. (Not that it makes a huge difference...)
Yeah, that's awesome! |
One other thought: It currently can potentially return an object with NaN's and/or Invalid Dates if parsing some of the values fails. That's probably not very useful, but I'm on the fence about what to do in that scenario:
I'm kind of leaning towards throwing an error as the default, but having a config option to do something else. |
Yea, exactly. I wrote a library to parse the
Given that the We could add a option to the |
After looking at ietf-wg-httpapi/ratelimit-headers#130 and https://datatracker.ietf.org/doc/rfc8941/ I added this to the list:
|
Moving this out of the readme so that I can publish the module without the todo list being immortalized.
Todo
RateLimit-Policy
headersparseCombinedRateLimitHeader
in a way that allows it to be included without pulling in the entire library?parseCombinedRateLimitHeader
operate in a single pass instead of 3fetch
fetch
fetch
XMLHttpRequest
The text was updated successfully, but these errors were encountered: