Skip to content

Commit

Permalink
add last known rate limit values to ApiClient
Browse files Browse the repository at this point in the history
fixes #281
  • Loading branch information
d-fischer committed Dec 25, 2021
1 parent c926e32 commit 2b36dbe
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 147 deletions.
2 changes: 1 addition & 1 deletion packages/api/package.json
Expand Up @@ -34,7 +34,7 @@
"dependencies": {
"@d-fischer/cache-decorators": "^3.0.0",
"@d-fischer/logger": "^4.0.0",
"@d-fischer/rate-limiter": "^0.4.4",
"@d-fischer/rate-limiter": "^0.5.0",
"@d-fischer/shared-utils": "^3.2.0",
"@twurple/api-call": "^5.1.0-pre.1",
"@twurple/common": "^5.1.0-pre.1",
Expand Down
21 changes: 21 additions & 0 deletions packages/api/src/ApiClient.ts
Expand Up @@ -346,6 +346,27 @@ export class ApiClient {
return new UnsupportedApi(this);
}

/**
* The last known rate limit for the Helix API.
*/
get lastKnownLimit(): number | null {
return this._helixRateLimiter.lastKnownLimit;
}

/**
* The last known remaining requests for the Helix API.
*/
get lastKnownRemainingRequests(): number | null {
return this._helixRateLimiter.lastKnownRemainingRequests;
}

/**
* The last known rate limit reset date for the Helix API.
*/
get lastKnownResetDate(): Date | null {
return this._helixRateLimiter.lastKnownResetDate;
}

/** @private */
get _authProvider(): AuthProvider {
return this._config.authProvider;
Expand Down

0 comments on commit 2b36dbe

Please sign in to comment.