diff options
author | mat <github@matdoes.dev> | 2021-05-09 20:05:14 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2021-05-09 20:05:14 -0500 |
commit | 58807d12eefe264e817d8dc4b7075dbb25e4c2d2 (patch) | |
tree | 53f7c02ea6cddcc5c053da56e57ddbc5755b02ac /build | |
parent | 919a610cf5fcb8c4714a3be147ab5461778bbf2f (diff) | |
download | skyblock-api-58807d12eefe264e817d8dc4b7075dbb25e4c2d2.tar.gz skyblock-api-58807d12eefe264e817d8dc4b7075dbb25e4c2d2.tar.bz2 skyblock-api-58807d12eefe264e817d8dc4b7075dbb25e4c2d2.zip |
temp debug stuff
Diffstat (limited to 'build')
-rw-r--r-- | build/constants.js | 4 | ||||
-rw-r--r-- | build/hypixelApi.js | 8 | ||||
-rw-r--r-- | build/index.js | 2 |
3 files changed, 11 insertions, 3 deletions
diff --git a/build/constants.js b/build/constants.js index 3c0c7e9..b657426 100644 --- a/build/constants.js +++ b/build/constants.js @@ -64,7 +64,8 @@ async function fetchGithubApi(method, route, headers, json) { }, headers), }); } - catch { + catch (err) { + console.log('bruh, errored', err); // 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); @@ -89,6 +90,7 @@ 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 ccae09b..b0d87fe 100644 --- a/build/hypixelApi.js +++ b/build/hypixelApi.js @@ -58,7 +58,8 @@ async function sendApiRequest({ path, key, args }) { fetchResponse = await node_fetch_1.default(fetchUrl, { agent: () => httpsAgent }); fetchJsonParsed = await fetchResponse.json(); } - catch { + catch (err) { + console.debug('error? ok retrying', err); // if there's an error, wait a second and try again await new Promise((resolve) => setTimeout(resolve, 1000)); return await sendApiRequest({ path, key, args }); @@ -76,12 +77,17 @@ 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 c7f1385..ba1e21a 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 = false; +exports.debug = true; // 200 requests over 5 minutes const limiter = express_rate_limit_1.default({ windowMs: 60 * 1000 * 5, |