From 03d01463e1fc8ddacf2bef5218395bc534e93bda Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Fri, 9 Apr 2021 14:41:23 +0000 Subject: [PATCH] deno fmt --- src/rest/create_request_body.ts | 2 +- src/rest/process_queue.ts | 31 +++++++++++++++---------------- src/rest/rest.ts | 4 +--- src/ws/handle_discord_payload.ts | 2 +- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/rest/create_request_body.ts b/src/rest/create_request_body.ts index 2b4434fc2..a5e55ede3 100644 --- a/src/rest/create_request_body.ts +++ b/src/rest/create_request_body.ts @@ -45,6 +45,6 @@ export function createRequestBody(queuedRequest: QueuedRequest) { body: queuedRequest.payload.body?.file || JSON.stringify(queuedRequest.payload.body), - method: queuedRequest.request.method, + method: queuedRequest.request.method.toUpperCase(), }; } diff --git a/src/rest/process_queue.ts b/src/rest/process_queue.ts index 24db6fe73..ae14d3c29 100644 --- a/src/rest/process_queue.ts +++ b/src/rest/process_queue.ts @@ -36,19 +36,18 @@ export async function processQueue(id: string) { // EXECUTE THE REQUEST // IF THIS IS A GET REQUEST, CHANGE THE BODY TO QUERY PARAMETERS - const query = queuedRequest.request.method.toUpperCase() === "GET" && - queuedRequest.payload.body - ? Object.entries(queuedRequest.payload.body) - .map( - ([key, value]) => - `${encodeURIComponent(key)}=${ - encodeURIComponent( - value as string, - ) - }`, - ) - .join("&") - : ""; + const query = + queuedRequest.request.method.toUpperCase() === "GET" && + queuedRequest.payload.body + ? Object.entries(queuedRequest.payload.body) + .map( + ([key, value]) => + `${encodeURIComponent(key)}=${encodeURIComponent( + value as string + )}` + ) + .join("&") + : ""; const urlToUse = queuedRequest.request.method.toUpperCase() === "GET" && query ? `${queuedRequest.request.url}?${query}` @@ -60,13 +59,13 @@ export async function processQueue(id: string) { try { const response = await fetch( urlToUse, - rest.createRequestBody(queuedRequest), + rest.createRequestBody(queuedRequest) ); rest.eventHandlers.fetched(queuedRequest.payload); const bucketIdFromHeaders = rest.processRequestHeaders( queuedRequest.request.url, - response.headers, + response.headers ); if (response.status < 200 || response.status >= 400) { @@ -124,7 +123,7 @@ export async function processQueue(id: string) { // IF IT HAS MAXED RETRIES SOMETHING SERIOUSLY WRONG. CANCEL OUT. if ( queuedRequest.payload.retryCount >= - queuedRequest.options.maxRetryCount + queuedRequest.options.maxRetryCount ) { rest.eventHandlers.retriesMaxed(queuedRequest.payload); queuedRequest.request.respond({ diff --git a/src/rest/rest.ts b/src/rest/rest.ts index a2853f8e0..856c176a1 100644 --- a/src/rest/rest.ts +++ b/src/rest/rest.ts @@ -21,9 +21,7 @@ export const rest = { ratelimitedPaths: new Map(), eventHandlers: { // BY DEFAULT WE WILL LOG ALL ERRORS TO CONSOLE. USER CAN CHOOSE TO OVERRIDE - error: function (_type, error) { - console.error(error); - }, + error: console.error, // PLACEHOLDERS TO ALLOW USERS TO CUSTOMIZE debug: function (_type, error) {}, fetching() {}, diff --git a/src/ws/handle_discord_payload.ts b/src/ws/handle_discord_payload.ts index a1ba8ddb8..548c346c3 100644 --- a/src/ws/handle_discord_payload.ts +++ b/src/ws/handle_discord_payload.ts @@ -4,7 +4,7 @@ import { ws } from "./ws.ts"; /** Handler for processing all dispatch payloads that should be sent/forwarded to another server/vps/process. */ export async function handleDiscordPayload( data: DiscordGatewayPayload, - shardId: number, + shardId: number ) { await fetch(ws.url, { headers: {