diff options
author | mat-1 <github@matdoes.dev> | 2021-06-02 00:41:52 +0000 |
---|---|---|
committer | mat-1 <github@matdoes.dev> | 2021-06-02 00:41:52 +0000 |
commit | 4d7552c19f85de7137457fd443b05dc9eb7d1e6c (patch) | |
tree | f250e824fe99b61a6ac5b73bb0000f42535f72db | |
parent | b14a077a9bc35384d7561fd1b39bdad389cc4a53 (diff) | |
download | skyblock-api-4d7552c19f85de7137457fd443b05dc9eb7d1e6c.tar.gz skyblock-api-4d7552c19f85de7137457fd443b05dc9eb7d1e6c.tar.bz2 skyblock-api-4d7552c19f85de7137457fd443b05dc9eb7d1e6c.zip |
Compiled TS into JS
-rw-r--r-- | build/hypixelApi.js | 17 | ||||
-rw-r--r-- | build/index.js | 2 |
2 files changed, 17 insertions, 2 deletions
diff --git a/build/hypixelApi.js b/build/hypixelApi.js index 9f54ef2..59a798c 100644 --- a/build/hypixelApi.js +++ b/build/hypixelApi.js @@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; var _a, _b, _c; Object.defineProperty(exports, "__esModule", { value: true }); -exports.sendApiRequest = exports.chooseApiKey = void 0; +exports.sendApiRequest = exports.getKeyUsage = exports.chooseApiKey = void 0; /** * Fetch the raw Hypixel API */ @@ -27,7 +27,7 @@ function chooseApiKey() { // find the api key with the lowest amount of uses let bestKeyUsage = null; let bestKey = null; - for (var key of util_1.shuffle(apiKeys)) { + for (let key of util_1.shuffle(apiKeys)) { const keyUsage = apiKeyUsage[key]; // if the key has never been used before, use it if (!keyUsage) @@ -44,6 +44,19 @@ function chooseApiKey() { return bestKey; } exports.chooseApiKey = chooseApiKey; +function getKeyUsage() { + let keyLimit = 0; + let keyUsage = 0; + for (let key of Object.values(apiKeyUsage)) { + keyLimit += key.limit; + keyUsage += key.limit - key.remaining; + } + return { + limit: keyLimit, + usage: keyUsage + }; +} +exports.getKeyUsage = getKeyUsage; /** Send an HTTP request to the Hypixel API */ async function sendApiRequest({ path, key, args }) { // Send a raw http request to api.hypixel.net, and return the parsed json diff --git a/build/index.js b/build/index.js index 1f628ea..f8479f3 100644 --- a/build/index.js +++ b/build/index.js @@ -29,6 +29,7 @@ const express_rate_limit_1 = __importDefault(require("express-rate-limit")); const constants = __importStar(require("./constants")); const discord = __importStar(require("./discord")); const express_1 = __importDefault(require("express")); +const hypixelApi_1 = require("./hypixelApi"); const app = express_1.default(); exports.debug = false; const mainSiteUrl = 'https://skyblock.matdoes.dev'; @@ -59,6 +60,7 @@ app.get('/', async (req, res) => { finishedCachingRawLeaderboards: database_1.finishedCachingRawLeaderboards, leaderboardUpdateMemberQueueSize: database_1.leaderboardUpdateMemberQueue.size, leaderboardUpdateProfileQueueSize: database_1.leaderboardUpdateProfileQueue.size, + key: hypixelApi_1.getKeyUsage() }); }); app.get('/player/:user', async (req, res) => { |