aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-05-01 19:04:52 -0500
committerGitHub <noreply@github.com>2021-05-01 19:04:52 -0500
commit4b78c2fbdfcdd9dcc794e4b0c17cfb6d88a1006b (patch)
tree6e8281984bef6d30cd2988fbf80bfcd22c4f668e /build
parent644e9c6629453b07844ca83fab7fbe9a3185b4b6 (diff)
downloadskyblock-api-4b78c2fbdfcdd9dcc794e4b0c17cfb6d88a1006b.tar.gz
skyblock-api-4b78c2fbdfcdd9dcc794e4b0c17cfb6d88a1006b.tar.bz2
skyblock-api-4b78c2fbdfcdd9dcc794e4b0c17cfb6d88a1006b.zip
Show minions that haven't been unlocked in response (#20)
* add minions that haven't been unlocked yet to response, and slightly optimize constants * remove most console.logs with console.debugs * mock constants
Diffstat (limited to 'build')
-rw-r--r--build/cleaners/skyblock/member.js2
-rw-r--r--build/cleaners/skyblock/minions.js44
-rw-r--r--build/constants.js147
-rw-r--r--build/database.js28
-rw-r--r--build/hypixel.js2
-rw-r--r--build/hypixelCached.js30
-rw-r--r--build/index.js2
7 files changed, 169 insertions, 86 deletions
diff --git a/build/cleaners/skyblock/member.js b/build/cleaners/skyblock/member.js
index ce322bc..218518d 100644
--- a/build/cleaners/skyblock/member.js
+++ b/build/cleaners/skyblock/member.js
@@ -59,7 +59,7 @@ async function cleanSkyBlockProfileMemberResponse(member, included = null) {
stats: stats_1.cleanProfileStats(member),
// this is used for leaderboards
rawHypixelStats: (_a = member.stats) !== null && _a !== void 0 ? _a : {},
- minions: minions_1.cleanMinions(member),
+ minions: await minions_1.cleanMinions(member),
fairy_souls: fairysouls_1.cleanFairySouls(member),
inventories: inventoriesIncluded ? await inventory_1.cleanInventories(member) : undefined,
objectives: objectives_1.cleanObjectives(member),
diff --git a/build/cleaners/skyblock/minions.js b/build/cleaners/skyblock/minions.js
index 0543e92..fae3c96 100644
--- a/build/cleaners/skyblock/minions.js
+++ b/build/cleaners/skyblock/minions.js
@@ -1,15 +1,36 @@
"use strict";
+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]; } });
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
Object.defineProperty(exports, "__esModule", { value: true });
exports.countUniqueMinions = exports.combineMinionArrays = exports.cleanMinions = void 0;
const hypixel_1 = require("../../hypixel");
+const constants = __importStar(require("../../constants"));
/**
* Clean the minions provided by Hypixel
* @param minionsRaw The minion data provided by the Hypixel API
*/
-function cleanMinions(data) {
+async function cleanMinions(member) {
var _a;
const minions = [];
- for (const minionRaw of (_a = data === null || data === void 0 ? void 0 : data.crafted_generators) !== null && _a !== void 0 ? _a : []) {
+ const processedMinionNames = new Set();
+ for (const minionRaw of (_a = member === null || member === void 0 ? void 0 : member.crafted_generators) !== null && _a !== void 0 ? _a : []) {
// do some regex magic to get the minion name and level
// examples of potential minion names: CLAY_11, PIG_1, MAGMA_CUBE_4
const minionName = minionRaw.split(/_\d/)[0].toLowerCase();
@@ -28,8 +49,25 @@ function cleanMinions(data) {
matchingMinion.levels.push(false);
// set the minion at that level to true
matchingMinion.levels[minionLevel - 1] = true;
+ processedMinionNames.add(minionName);
}
- return minions;
+ const allMinionNames = new Set(await constants.fetchMinions());
+ for (const minionName of processedMinionNames) {
+ if (!allMinionNames.has(minionName)) {
+ constants.addMinions(Array.from(processedMinionNames));
+ break;
+ }
+ }
+ for (const minionName of allMinionNames) {
+ if (!processedMinionNames.has(minionName)) {
+ processedMinionNames.add(minionName);
+ minions.push({
+ name: minionName,
+ levels: new Array(hypixel_1.maxMinion).fill(false)
+ });
+ }
+ }
+ return minions.sort((a, b) => a.name > b.name ? 1 : (a.name < b.name ? -1 : 0));
}
exports.cleanMinions = cleanMinions;
/**
diff --git a/build/constants.js b/build/constants.js
index 96ae2e7..861eae6 100644
--- a/build/constants.js
+++ b/build/constants.js
@@ -2,25 +2,47 @@
/**
* Fetch and edit constants from the skyblock-constants repo
*/
+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]; } });
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+}));
+var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+});
+var __importStar = (this && this.__importStar) || function (mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
-exports.addSlayers = exports.fetchSlayers = exports.addZones = exports.fetchZones = exports.addSkills = exports.fetchSkills = exports.addCollections = exports.fetchCollections = exports.addStats = exports.fetchStats = exports.addJSONConstants = void 0;
-const node_fetch_1 = __importDefault(require("node-fetch"));
-const https_1 = require("https");
+exports.addMinions = exports.fetchMinions = exports.addSlayers = exports.fetchSlayers = exports.addZones = exports.fetchZones = exports.addSkills = exports.fetchSkills = exports.addCollections = exports.fetchCollections = exports.addStats = exports.fetchStats = exports.addJSONConstants = exports.fetchJSONConstant = void 0;
+// we have to do this so we can mock the function from the tests properly
+const constants = __importStar(require("./constants"));
const node_cache_1 = __importDefault(require("node-cache"));
const queue_promise_1 = __importDefault(require("queue-promise"));
+const node_fetch_1 = __importDefault(require("node-fetch"));
+const https_1 = require("https");
+const _1 = require(".");
const httpsAgent = new https_1.Agent({
keepAlive: true
});
const githubApiBase = 'https://api.github.com';
const owner = 'skyblockstats';
const repo = 'skyblock-constants';
-// we use a queue for editing so it doesnt hit the github ratelimit as much
+// we use a queue for editing so it always utilizes the cache if possible, and to avoid hitting the github rateimit
const queue = new queue_promise_1.default({
concurrent: 1,
- interval: 500
+ interval: 10
});
/**
* Send a request to the GitHub API
@@ -31,6 +53,8 @@ const queue = new queue_promise_1.default({
*/
async function fetchGithubApi(method, route, headers, json) {
try {
+ if (_1.debug)
+ console.debug('fetching github api', method, route);
return await node_fetch_1.default(githubApiBase + route, {
agent: () => httpsAgent,
body: json ? JSON.stringify(json) : null,
@@ -56,20 +80,24 @@ const fileCache = new node_cache_1.default({
* Fetch a file from skyblock-constants
* @param path The file path, for example stats.json
*/
-async function fetchFile(path) {
- if (fileCache.has(path))
- return fileCache.get(path);
- const r = await fetchGithubApi('GET', `/repos/${owner}/${repo}/contents/${path}`, {
- 'Accept': 'application/vnd.github.v3+json',
+function fetchFile(path) {
+ return new Promise(resolve => {
+ queue.enqueue(async () => {
+ if (fileCache.has(path))
+ return resolve(fileCache.get(path));
+ const r = await fetchGithubApi('GET', `/repos/${owner}/${repo}/contents/${path}`, {
+ 'Accept': 'application/vnd.github.v3+json',
+ });
+ const data = await r.json();
+ const file = {
+ path: data.path,
+ content: Buffer.from(data.content, data.encoding).toString(),
+ sha: data.sha
+ };
+ fileCache.set(path, file);
+ resolve(file);
+ });
});
- const data = await r.json();
- const file = {
- path: data.path,
- content: Buffer.from(data.content, data.encoding).toString(),
- sha: data.sha
- };
- fileCache.set(path, file);
- return file;
}
/**
* Edit a file on skyblock-constants
@@ -92,6 +120,7 @@ async function editFile(file, message, newContent) {
});
}
async function fetchJSONConstant(filename) {
+ console.log('actually fetchJSONConstant');
const file = await fetchFile(filename);
try {
return JSON.parse(file.content);
@@ -101,83 +130,99 @@ async function fetchJSONConstant(filename) {
return [];
}
}
+exports.fetchJSONConstant = fetchJSONConstant;
/** Add stats to skyblock-constants. This has caching so it's fine to call many times */
async function addJSONConstants(filename, addingValues, unit = 'stat') {
if (addingValues.length === 0)
return; // no stats provided, just return
- queue.enqueue(async () => {
- const file = await fetchFile(filename);
- if (!file.path)
- return;
- let oldStats;
- try {
- oldStats = JSON.parse(file.content);
- }
- catch {
- // invalid json, set it as an empty array
- oldStats = [];
- }
- const updatedStats = oldStats
- .concat(addingValues)
- // remove duplicates
- .filter((value, index, array) => array.indexOf(value) === index)
- .sort((a, b) => a.localeCompare(b));
- const newStats = updatedStats.filter(value => !oldStats.includes(value));
- // there's not actually any new stats, just return
- if (newStats.length === 0)
- return;
- const commitMessage = newStats.length >= 2 ? `Add ${newStats.length} new ${unit}s` : `Add '${newStats[0]}' ${unit}`;
+ let file = await fetchFile(filename);
+ if (!file.path)
+ return;
+ let oldStats;
+ try {
+ oldStats = JSON.parse(file.content);
+ }
+ catch {
+ // invalid json, set it as an empty array
+ oldStats = [];
+ }
+ const updatedStats = oldStats
+ .concat(addingValues)
+ // remove duplicates
+ .filter((value, index, array) => array.indexOf(value) === index)
+ .sort((a, b) => a.localeCompare(b));
+ const newStats = updatedStats.filter(value => !oldStats.includes(value));
+ // there's not actually any new stats, just return
+ if (newStats.length === 0)
+ return;
+ const commitMessage = newStats.length >= 2 ? `Add ${newStats.length} new ${unit}s` : `Add '${newStats[0]}' ${unit}`;
+ try {
await editFile(file, commitMessage, JSON.stringify(updatedStats, null, 2));
- });
+ }
+ catch {
+ // the file probably changed or something, try again
+ file = await fetchFile(filename);
+ await editFile(file, commitMessage, JSON.stringify(updatedStats, null, 2));
+ }
}
exports.addJSONConstants = addJSONConstants;
/** Fetch all the known SkyBlock stats as an array of strings */
async function fetchStats() {
- return await fetchJSONConstant('stats.json');
+ return await constants.fetchJSONConstant('stats.json');
}
exports.fetchStats = fetchStats;
/** Add stats to skyblock-constants. This has caching so it's fine to call many times */
async function addStats(addingStats) {
- await addJSONConstants('stats.json', addingStats, 'stat');
+ await constants.addJSONConstants('stats.json', addingStats, 'stat');
}
exports.addStats = addStats;
/** Fetch all the known SkyBlock collections as an array of strings */
async function fetchCollections() {
- return await fetchJSONConstant('collections.json');
+ return await constants.fetchJSONConstant('collections.json');
}
exports.fetchCollections = fetchCollections;
/** Add collections to skyblock-constants. This has caching so it's fine to call many times */
async function addCollections(addingCollections) {
- await addJSONConstants('collections.json', addingCollections, 'collection');
+ await constants.addJSONConstants('collections.json', addingCollections, 'collection');
}
exports.addCollections = addCollections;
/** Fetch all the known SkyBlock collections as an array of strings */
async function fetchSkills() {
- return await fetchJSONConstant('skills.json');
+ return await constants.fetchJSONConstant('skills.json');
}
exports.fetchSkills = fetchSkills;
/** Add skills to skyblock-constants. This has caching so it's fine to call many times */
async function addSkills(addingSkills) {
- await addJSONConstants('skills.json', addingSkills, 'skill');
+ await constants.addJSONConstants('skills.json', addingSkills, 'skill');
}
exports.addSkills = addSkills;
/** Fetch all the known SkyBlock collections as an array of strings */
async function fetchZones() {
- return await fetchJSONConstant('zones.json');
+ return await constants.fetchJSONConstant('zones.json');
}
exports.fetchZones = fetchZones;
/** Add skills to skyblock-constants. This has caching so it's fine to call many times */
async function addZones(addingZones) {
- await addJSONConstants('zones.json', addingZones, 'zone');
+ await constants.addJSONConstants('zones.json', addingZones, 'zone');
}
exports.addZones = addZones;
/** Fetch all the known SkyBlock slayer names as an array of strings */
async function fetchSlayers() {
- return await fetchJSONConstant('slayers.json');
+ return await constants.fetchJSONConstant('slayers.json');
}
exports.fetchSlayers = fetchSlayers;
/** Add skills to skyblock-constants. This has caching so it's fine to call many times */
async function addSlayers(addingSlayers) {
- await addJSONConstants('slayers.json', addingSlayers, 'slayer');
+ await constants.addJSONConstants('slayers.json', addingSlayers, 'slayer');
}
exports.addSlayers = addSlayers;
+/** Fetch all the known SkyBlock slayer names as an array of strings */
+async function fetchMinions() {
+ return await constants.fetchJSONConstant('minions.json');
+}
+exports.fetchMinions = fetchMinions;
+/** Add skills to skyblock-constants. This has caching so it's fine to call many times */
+async function addMinions(addingMinions) {
+ await constants.addJSONConstants('minions.json', addingMinions, 'minion');
+}
+exports.addMinions = addMinions;
diff --git a/build/database.js b/build/database.js
index 45b0179..9557668 100644
--- a/build/database.js
+++ b/build/database.js
@@ -355,27 +355,27 @@ async function getApplicableProfileLeaderboardAttributes(profile) {
}
/** Update the member's leaderboard data on the server if applicable */
async function updateDatabaseMember(member, profile) {
- if (_1.debug)
- console.log('updateDatabaseMember', member.username);
if (!client)
return; // the db client hasn't been initialized
+ if (_1.debug)
+ console.debug('updateDatabaseMember', member.username);
// the member's been updated too recently, just return
if (recentlyUpdated.get(profile.uuid + member.uuid))
return;
// store the member in recentlyUpdated so it cant update for 3 more minutes
recentlyUpdated.set(profile.uuid + member.uuid, true);
if (_1.debug)
- console.log('adding member to leaderboards', member.username);
+ console.debug('adding member to leaderboards', member.username);
await constants.addStats(Object.keys(member.rawHypixelStats));
await constants.addCollections(member.collections.map(coll => coll.name));
await constants.addSkills(member.skills.map(skill => skill.name));
await constants.addZones(member.visited_zones.map(zone => zone.name));
await constants.addSlayers(member.slayers.bosses.map(s => s.raw_name));
if (_1.debug)
- console.log('done constants..');
+ console.debug('done constants..');
const leaderboardAttributes = await getApplicableMemberLeaderboardAttributes(member);
if (_1.debug)
- console.log('done getApplicableMemberLeaderboardAttributes..', leaderboardAttributes, member.username, profile.name);
+ console.debug('done getApplicableMemberLeaderboardAttributes..', leaderboardAttributes, member.username, profile.name);
await memberLeaderboardsCollection.updateOne({
uuid: member.uuid,
profile: profile.uuid
@@ -402,7 +402,7 @@ async function updateDatabaseMember(member, profile) {
cachedRawLeaderboards.set(attributeName, newRawLeaderboard);
}
if (_1.debug)
- console.log('added member to leaderboards', member.username, leaderboardAttributes);
+ console.debug('added member to leaderboards', member.username, leaderboardAttributes);
}
exports.updateDatabaseMember = updateDatabaseMember;
/**
@@ -410,20 +410,20 @@ exports.updateDatabaseMember = updateDatabaseMember;
* This will not also update the members, you have to call updateDatabaseMember separately for that
*/
async function updateDatabaseProfile(profile) {
- if (_1.debug)
- console.log('updateDatabaseProfile', profile.name);
if (!client)
return; // the db client hasn't been initialized
+ if (_1.debug)
+ console.debug('updateDatabaseProfile', profile.name);
// the profile's been updated too recently, just return
if (recentlyUpdated.get(profile.uuid + 'profile'))
return;
// store the profile in recentlyUpdated so it cant update for 3 more minutes
recentlyUpdated.set(profile.uuid + 'profile', true);
if (_1.debug)
- console.log('adding profile to leaderboards', profile.name);
+ console.debug('adding profile to leaderboards', profile.name);
const leaderboardAttributes = await getApplicableProfileLeaderboardAttributes(profile);
if (_1.debug)
- console.log('done getApplicableProfileLeaderboardAttributes..', leaderboardAttributes, profile.name);
+ console.debug('done getApplicableProfileLeaderboardAttributes..', leaderboardAttributes, profile.name);
await profileLeaderboardsCollection.updateOne({
uuid: profile.uuid
}, {
@@ -451,7 +451,7 @@ async function updateDatabaseProfile(profile) {
cachedRawLeaderboards.set(attributeName, newRawLeaderboard);
}
if (_1.debug)
- console.log('added profile to leaderboards', profile.name, leaderboardAttributes);
+ console.debug('added profile to leaderboards', profile.name, leaderboardAttributes);
}
exports.updateDatabaseProfile = updateDatabaseProfile;
const leaderboardUpdateMemberQueue = new queue_promise_1.default({
@@ -500,7 +500,7 @@ async function fetchAllLeaderboards(fast) {
const leaderboards = await fetchAllMemberLeaderboardAttributes();
// shuffle so if the application is restarting many times itll still be useful
if (_1.debug)
- console.log('Caching leaderboards!');
+ console.debug('Caching leaderboards!');
for (const leaderboard of util_1.shuffle(leaderboards)) {
if (!fast)
// wait 2 seconds so it doesnt use as much ram
@@ -508,10 +508,10 @@ async function fetchAllLeaderboards(fast) {
await fetchMemberLeaderboard(leaderboard);
}
if (_1.debug)
- console.log('Finished caching leaderboards!');
+ console.debug('Finished caching leaderboards!');
}
// make sure it's not in a test
-if (typeof global.it !== 'function') {
+if (!globalThis.isTest) {
connect().then(() => {
// when it connects, cache the leaderboards and remove bad members
removeBadMemberLeaderboardAttributes();
diff --git a/build/hypixel.js b/build/hypixel.js
index 9e9007e..d77e1ae 100644
--- a/build/hypixel.js
+++ b/build/hypixel.js
@@ -69,7 +69,7 @@ async function fetchUser({ user, uuid, username }, included = ['player']) {
if (!uuid) {
// the user doesn't exist.
if (_1.debug)
- console.log('error:', user, 'doesnt exist');
+ console.debug('error:', user, 'doesnt exist');
return null;
}
const includePlayers = included.includes('player');
diff --git a/build/hypixelCached.js b/build/hypixelCached.js
index c9e4876..c5a027c 100644
--- a/build/hypixelCached.js
+++ b/build/hypixelCached.js
@@ -110,7 +110,7 @@ async function uuidFromUser(user) {
return uuid;
}
if (_1.debug)
- console.log('Cache miss: uuidFromUser', user);
+ console.debug('Cache miss: uuidFromUser', user);
// set it as waitForCacheSet (a promise) in case uuidFromUser gets called while its fetching mojang
exports.usernameCache.set(util_1.undashUuid(user), waitForCacheSet(exports.usernameCache, user, user));
// not cached, actually fetch mojang api now
@@ -134,11 +134,11 @@ exports.uuidFromUser = uuidFromUser;
async function usernameFromUser(user) {
if (exports.usernameCache.has(util_1.undashUuid(user))) {
if (_1.debug)
- console.log('Cache hit! usernameFromUser', user);
+ console.debug('Cache hit! usernameFromUser', user);
return exports.usernameCache.get(util_1.undashUuid(user));
}
if (_1.debug)
- console.log('Cache miss: usernameFromUser', user);
+ console.debug('Cache miss: usernameFromUser', user);
let { uuid, username } = await mojang.profileFromUser(user);
uuid = util_1.undashUuid(uuid);
exports.usernameCache.set(uuid, username);
@@ -181,7 +181,7 @@ async function fetchBasicPlayer(user) {
return exports.basicPlayerCache.get(playerUuid);
const player = await fetchPlayer(playerUuid);
if (!player)
- console.log('no player? this should never happen', user);
+ console.debug('no player? this should never happen', user);
delete player.profiles;
return player;
}
@@ -189,11 +189,11 @@ exports.fetchBasicPlayer = fetchBasicPlayer;
async function fetchSkyblockProfiles(playerUuid) {
if (exports.profilesCache.has(playerUuid)) {
if (_1.debug)
- console.log('Cache hit! fetchSkyblockProfiles', playerUuid);
+ console.debug('Cache hit! fetchSkyblockProfiles', playerUuid);
return exports.profilesCache.get(playerUuid);
}
if (_1.debug)
- console.log('Cache miss: fetchSkyblockProfiles', playerUuid);
+ console.debug('Cache miss: fetchSkyblockProfiles', playerUuid);
const profiles = await hypixel.fetchMemberProfilesUncached(playerUuid);
const basicProfiles = [];
// create the basicProfiles array
@@ -225,11 +225,11 @@ async function fetchBasicProfiles(user) {
return; // invalid player, just return
if (exports.basicProfilesCache.has(playerUuid)) {
if (_1.debug)
- console.log('Cache hit! fetchBasicProfiles', playerUuid);
+ console.debug('Cache hit! fetchBasicProfiles', playerUuid);
return exports.basicProfilesCache.get(playerUuid);
}
if (_1.debug)
- console.log('Cache miss: fetchBasicProfiles', user);
+ console.debug('Cache miss: fetchBasicProfiles', user);
const player = await fetchPlayer(playerUuid);
const profiles = player.profiles;
exports.basicProfilesCache.set(playerUuid, profiles);
@@ -247,11 +247,11 @@ async function fetchProfileUuid(user, profile) {
// if a profile wasn't provided, return
if (!profile) {
if (_1.debug)
- console.log('no profile provided?', user, profile);
+ console.debug('no profile provided?', user, profile);
return null;
}
if (_1.debug)
- console.log('Cache miss: fetchProfileUuid', user);
+ console.debug('Cache miss: fetchProfileUuid', user);
const profiles = await fetchBasicProfiles(user);
if (!profiles)
return; // user probably doesnt exist
@@ -275,11 +275,11 @@ async function fetchProfile(user, profile) {
if (exports.profileCache.has(profileUuid)) {
// we have the profile cached, return it :)
if (_1.debug)
- console.log('Cache hit! fetchProfile', profileUuid);
+ console.debug('Cache hit! fetchProfile', profileUuid);
return exports.profileCache.get(profileUuid);
}
if (_1.debug)
- console.log('Cache miss: fetchProfile', user, profile);
+ console.debug('Cache miss: fetchProfile', user, profile);
const profileName = await fetchProfileName(user, profile);
const cleanProfile = await hypixel.fetchMemberProfileUncached(playerUuid, profileUuid);
// we know the name from fetchProfileName, so set it here
@@ -296,7 +296,7 @@ async function fetchBasicProfileFromUuid(profileUuid) {
if (exports.profileCache.has(profileUuid)) {
// we have the profile cached, return it :)
if (_1.debug)
- console.log('Cache hit! fetchBasicProfileFromUuid', profileUuid);
+ console.debug('Cache hit! fetchBasicProfileFromUuid', profileUuid);
const profile = exports.profileCache.get(profileUuid);
return {
uuid: profile.uuid,
@@ -326,11 +326,11 @@ async function fetchProfileName(user, profile) {
if (exports.profileNameCache.has(`${playerUuid}.${profileUuid}`)) {
// Return the profile name if it's cached
if (_1.debug)
- console.log('Cache hit! fetchProfileName', profileUuid);
+ console.debug('Cache hit! fetchProfileName', profileUuid);
return exports.profileNameCache.get(`${playerUuid}.${profileUuid}`);
}
if (_1.debug)
- console.log('Cache miss: fetchProfileName', user, profile);
+ console.debug('Cache miss: fetchProfileName', user, profile);
const basicProfiles = await fetchBasicProfiles(playerUuid);
let profileName;
for (const basicProfile of basicProfiles)
diff --git a/build/index.js b/build/index.js
index 0a6944c..f499c21 100644
--- a/build/index.js
+++ b/build/index.js
@@ -52,5 +52,5 @@ app.get('/leaderboards', async (req, res) => {
res.json(await database_1.fetchAllLeaderboardsCategorized());
});
// only run the server if it's not doing tests
-if (typeof global.it !== 'function')
+if (!globalThis.isTest)
app.listen(8080, () => console.log('App started :)'));