aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/hypixel.js3
-rw-r--r--build/hypixelApi.js5
-rw-r--r--build/hypixelCached.js7
-rw-r--r--build/index.js7
-rw-r--r--build/mojang.js3
-rw-r--r--build/util.js4
6 files changed, 23 insertions, 6 deletions
diff --git a/build/hypixel.js b/build/hypixel.js
index 5dd45bb..e72ab8c 100644
--- a/build/hypixel.js
+++ b/build/hypixel.js
@@ -1,4 +1,7 @@
"use strict";
+/**
+ * Fetch the clean Hypixel API
+ */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
diff --git a/build/hypixelApi.js b/build/hypixelApi.js
index 5cbd829..2d9d10d 100644
--- a/build/hypixelApi.js
+++ b/build/hypixelApi.js
@@ -4,6 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.sendApiRequest = exports.chooseApiKey = void 0;
+/**
+ * Fetch the raw Hypixel API
+ */
const node_fetch_1 = __importDefault(require("node-fetch"));
const util_1 = require("./util");
const https_1 = require("https");
@@ -13,7 +16,7 @@ const httpsAgent = new https_1.Agent({
keepAlive: true
});
/* Lower level code related to the Hypixel api */
-const apiKeys = process.env.keys.split(' ');
+const apiKeys = process.env.hypixel_keys.split(' ');
const apiKeyUsage = {};
const baseHypixelAPI = 'https://api.hypixel.net';
/** Choose the best current API key */
diff --git a/build/hypixelCached.js b/build/hypixelCached.js
index c874089..9c63558 100644
--- a/build/hypixelCached.js
+++ b/build/hypixelCached.js
@@ -1,4 +1,7 @@
"use strict";
+/**
+ * Fetch the clean and cached Hypixel API
+ */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -27,10 +30,6 @@ const node_cache_1 = __importDefault(require("node-cache"));
const mojang = __importStar(require("./mojang"));
const hypixel = __importStar(require("./hypixel"));
const util_1 = require("./util");
-/**
-Hypixel... but with caching
-All the caching in this project is done here!
-*/
// cache usernames for 4 hours
const usernameCache = new node_cache_1.default({
stdTTL: 60 * 60 * 4,
diff --git a/build/index.js b/build/index.js
index bfc8b8d..91fdc29 100644
--- a/build/index.js
+++ b/build/index.js
@@ -6,6 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = __importDefault(require("express"));
const hypixel_1 = require("./hypixel");
const app = express_1.default();
+app.use((req, res, next) => {
+ if (process.env.key && req.headers.key !== process.env.key)
+ // if a key is set in process.env and the header doesn't match return an error
+ // TODO: make this have a status code
+ return res.json({ error: 'Key in header must match key in env' });
+ next();
+});
app.get('/', async (req, res) => {
res.json({ ok: true });
});
diff --git a/build/mojang.js b/build/mojang.js
index 981bf31..344e377 100644
--- a/build/mojang.js
+++ b/build/mojang.js
@@ -1,4 +1,7 @@
"use strict";
+/**
+ * Fetch the Mojang username API through api.ashcon.app
+ */
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
diff --git a/build/util.js b/build/util.js
index 4c7fe64..3350acf 100644
--- a/build/util.js
+++ b/build/util.js
@@ -1,5 +1,7 @@
"use strict";
-/* Utility functions (not related to Hypixel) */
+/**
+ * Random utility functions that are not related to Hypixel
+ */
Object.defineProperty(exports, "__esModule", { value: true });
exports.colorCodeFromName = exports.minecraftColorCodes = exports.shuffle = exports.jsonToQuery = exports.queryToJson = exports.undashUuid = void 0;
function undashUuid(uuid) {