Skip to content
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

feat(rest)!: allow passing tokens per request #10682

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ckohen
Copy link
Member

@ckohen ckohen commented Jan 3, 2025

BREAKING CHANGE: RequestData.authPrefix has been removed in favor of RequestData.auth.prefix

Please describe the changes this PR makes and why it should be merged:

This allows passing a token when making a request (mostly useful for OAuth endpoints) and moves the token prefix into the same object as it didn't make sense having it separate.

This separates handlers based on the token used to isolate (non-global) ratelimits. There is a chance that ratelimits are hit if a bucket spans tokens. It does respect bucket hashes, so after the first request with each token they will be bucketed together.

Fixes DJS-41

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
  • This PR changes the library's interface (methods or parameters added)
  • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)

@ckohen ckohen requested review from a team and iCrawl as code owners January 3, 2025 08:30
Copy link

vercel bot commented Jan 3, 2025

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

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Jan 3, 2025 11:58pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Jan 3, 2025 11:58pm

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

Attention: Patch coverage is 81.81818% with 4 lines in your changes missing coverage. Please review.

Project coverage is 37.99%. Comparing base (9fea069) to head (08618ab).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ackages/rest/src/lib/handlers/SequentialHandler.ts 42.85% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10682      +/-   ##
==========================================
+ Coverage   37.96%   37.99%   +0.02%     
==========================================
  Files         239      239              
  Lines       14877    14889      +12     
  Branches     1377     1385       +8     
==========================================
+ Hits         5648     5657       +9     
- Misses       9218     9221       +3     
  Partials       11       11              
Flag Coverage Δ
guide 0.58% <ø> (ø)
proxy 64.63% <ø> (ø)
rest 87.33% <81.81%> (-0.15%) ⬇️
ws 34.45% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

BREAKING CHANGE: `RequestData.authPrefix` has been removed in favor of `RequestData.auth.prefix`
@ckohen ckohen force-pushed the refactor/rest/auth-data branch from 5453148 to 1bf3ba4 Compare January 3, 2025 11:37
@ckohen ckohen changed the title refactor(rest)!: replace auth boolean with authdata feat(rest)!: allow passing tokens per request Jan 3, 2025
packages/rest/src/lib/utils/types.ts Outdated Show resolved Hide resolved
packages/rest/src/lib/utils/types.ts Outdated Show resolved Hide resolved
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

3 participants