mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 17:43:30 +01:00
feat: proxy container (#8000)
This commit is contained in:
@@ -33,6 +33,9 @@ export function proxyRequests(rest: REST): RequestHandler {
|
||||
// This type cast is technically incorrect, but we want Discord to throw Method Not Allowed for us
|
||||
method: method as RequestMethod,
|
||||
passThroughBody: true,
|
||||
headers: {
|
||||
'Content-Type': req.headers['content-type']!,
|
||||
},
|
||||
});
|
||||
|
||||
await populateSuccessfulResponse(res, discordResponse);
|
||||
|
||||
@@ -30,7 +30,6 @@ export async function populateSuccessfulResponse(res: ServerResponse, data: Disp
|
||||
*/
|
||||
export function populateGeneralErrorResponse(res: ServerResponse, error: DiscordAPIError | HTTPError): void {
|
||||
res.statusCode = error.status;
|
||||
res.statusMessage = error.message;
|
||||
|
||||
if ('rawError' in error) {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
@@ -48,6 +47,10 @@ export function populateRatelimitErrorResponse(res: ServerResponse, error: RateL
|
||||
res.setHeader('Retry-After', error.timeToReset / 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates a server response with data relevant for a time out
|
||||
* @param res The sever response to populate
|
||||
*/
|
||||
export function populateAbortErrorResponse(res: ServerResponse): void {
|
||||
res.statusCode = 504;
|
||||
res.statusMessage = 'Upstream timed out';
|
||||
|
||||
Reference in New Issue
Block a user