feat(REST): dynamic rate limit offsets (#10099)

* feat(REST): dynamic rate limit offsets

* chore: update tests

* chore: better doc comment

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

* fix: don't overlook globalReset

Co-authored-by: ckohen <chaikohen@gmail.com>

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: ckohen <chaikohen@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
DD
2024-01-30 11:29:42 +02:00
committed by GitHub
parent fc1f8ae374
commit 278396e815
6 changed files with 44 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
import { MockAgent, setGlobalDispatcher, type Interceptable } from 'undici';
import { beforeEach, afterEach, test, expect } from 'vitest';
import { REST } from '../src/index.js';
import { normalizeRateLimitOffset } from '../src/lib/utils/utils.js';
import { genPath } from './util.js';
const api = new REST();
@@ -36,5 +37,5 @@ test('no token', async () => {
test('negative offset', () => {
const badREST = new REST({ offset: -5_000 });
expect(badREST.options.offset).toEqual(0);
expect(normalizeRateLimitOffset(badREST.options.offset, 'hehe :3')).toEqual(0);
});