mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
feat: proxy container (#8000)
This commit is contained in:
15
packages/proxy-container/src/index.ts
Normal file
15
packages/proxy-container/src/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { createServer } from 'node:http';
|
||||
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);
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
const server = createServer(proxyRequests(api));
|
||||
|
||||
const port = parseInt(process.env.PORT ?? '8080', 10);
|
||||
server.listen(port, () => console.log(`Listening on port ${port}`));
|
||||
Reference in New Issue
Block a user