refactor(proxy): rely on auth header instead (#9422)

* refactor(proxy): rely on auth header instead

* chore: typo

* chore: language

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

* chore: more language

Co-authored-by: Aura Román <kyradiscord@gmail.com>

* chore: more language nitpicks

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

* fix: unnecessary async

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: Aura Román <kyradiscord@gmail.com>
Co-authored-by: ckohen <chaikohen@gmail.com>
This commit is contained in:
DD
2023-04-21 23:36:15 +03:00
committed by GitHub
parent 3e01f91bbb
commit a49ed0a2d5
4 changed files with 44 additions and 32 deletions

View File

@@ -3,12 +3,8 @@ import process from 'node:process';
import { proxyRequests } from '@discordjs/proxy';
import { REST } from '@discordjs/rest';
if (!process.env.DISCORD_TOKEN) {
throw new Error('A DISCORD_TOKEN env var is required');
}
// We want to let upstream handle retrying
const api = new REST({ rejectOnRateLimit: () => true, retries: 0 }).setToken(process.env.DISCORD_TOKEN);
const api = new REST({ rejectOnRateLimit: () => true, retries: 0 });
const server = createServer(proxyRequests(api));
const port = Number.parseInt(process.env.PORT ?? '8080', 10);