diff options
-rw-r--r-- | build/constants.js | 4 | ||||
-rw-r--r-- | build/hypixelApi.js | 8 | ||||
-rw-r--r-- | build/index.js | 2 | ||||
-rw-r--r-- | src/constants.ts | 4 | ||||
-rw-r--r-- | src/hypixelApi.ts | 9 | ||||
-rw-r--r-- | src/index.ts | 2 |
6 files changed, 6 insertions, 23 deletions
diff --git a/build/constants.js b/build/constants.js index b657426..3c0c7e9 100644 --- a/build/constants.js +++ b/build/constants.js @@ -64,8 +64,7 @@ async function fetchGithubApi(method, route, headers, json) { }, headers), }); } - catch (err) { - console.log('bruh, errored', err); + catch { // if there's an error, wait a second and try again await new Promise((resolve) => setTimeout(resolve, 1000)); return await fetchGithubApi(method, route, headers, json); @@ -90,7 +89,6 @@ function fetchFile(path) { 'Accept': 'application/vnd.github.v3+json', }); const data = await r.json(); - console.log('ok github api returned'); const file = { path: data.path, content: Buffer.from(data.content, data.encoding).toString(), diff --git a/build/hypixelApi.js b/build/hypixelApi.js index b0d87fe..ccae09b 100644 --- a/build/hypixelApi.js +++ b/build/hypixelApi.js @@ -58,8 +58,7 @@ async function sendApiRequest({ path, key, args }) { fetchResponse = await node_fetch_1.default(fetchUrl, { agent: () => httpsAgent }); fetchJsonParsed = await fetchResponse.json(); } - catch (err) { - console.debug('error? ok retrying', err); + catch { // if there's an error, wait a second and try again await new Promise((resolve) => setTimeout(resolve, 1000)); return await sendApiRequest({ path, key, args }); @@ -77,17 +76,12 @@ async function sendApiRequest({ path, key, args }) { reset: Date.now() + parseInt(fetchResponse.headers['ratelimit-reset']) * 1000 }; if (fetchJsonParsed.throttle) { - console.log('bruh, throttled'); if (apiKeyUsage[key]) apiKeyUsage[key].remaining = 0; // if it's throttled, wait 10 seconds and try again await new Promise((resolve) => setTimeout(resolve, 10000)); return await sendApiRequest({ path, key, args }); } - console.log(path, args, fetchJsonParsed.success); - if (!fetchJsonParsed.success) { - console.log(fetchJsonParsed); - } return fetchJsonParsed; } exports.sendApiRequest = sendApiRequest; diff --git a/build/index.js b/build/index.js index ba1e21a..c7f1385 100644 --- a/build/index.js +++ b/build/index.js @@ -29,7 +29,7 @@ const express_rate_limit_1 = __importDefault(require("express-rate-limit")); const constants = __importStar(require("./constants")); const express_1 = __importDefault(require("express")); const app = express_1.default(); -exports.debug = true; +exports.debug = false; // 200 requests over 5 minutes const limiter = express_rate_limit_1.default({ windowMs: 60 * 1000 * 5, diff --git a/src/constants.ts b/src/constants.ts index 6c5c1c5..52c104c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -47,8 +47,7 @@ async function fetchGithubApi(method: string, route: string, headers?: any, json }, headers), } ) - } catch (err) { - console.log('bruh, errored', err) + } catch { // if there's an error, wait a second and try again await new Promise((resolve) => setTimeout(resolve, 1000)) return await fetchGithubApi(method, route, headers, json) @@ -87,7 +86,6 @@ function fetchFile(path: string): Promise<GithubFile> { }, ) const data = await r.json() - console.log('ok github api returned') const file = { path: data.path, diff --git a/src/hypixelApi.ts b/src/hypixelApi.ts index 35d46cb..fdb4535 100644 --- a/src/hypixelApi.ts +++ b/src/hypixelApi.ts @@ -145,8 +145,7 @@ export async function sendApiRequest({ path, key, args }): Promise<HypixelRespon { agent: () => httpsAgent } ) fetchJsonParsed = await fetchResponse.json() - } catch (err) { - console.debug('error? ok retrying', err) + } catch { // if there's an error, wait a second and try again await new Promise((resolve) => setTimeout(resolve, 1000)) return await sendApiRequest({ path, key, args }) @@ -167,18 +166,12 @@ export async function sendApiRequest({ path, key, args }): Promise<HypixelRespon } if (fetchJsonParsed.throttle) { - console.log('bruh, throttled') if (apiKeyUsage[key]) apiKeyUsage[key].remaining = 0 // if it's throttled, wait 10 seconds and try again await new Promise((resolve) => setTimeout(resolve, 10000)) return await sendApiRequest({ path, key, args }) } - - console.log(path, args, fetchJsonParsed.success) - if (!fetchJsonParsed.success) { - console.log(fetchJsonParsed) - } return fetchJsonParsed } diff --git a/src/index.ts b/src/index.ts index 6f3b94f..1652428 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,7 @@ import express from 'express' const app = express() -export const debug = true +export const debug = false // 200 requests over 5 minutes |