aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authormat-1 <github@matdoes.dev>2021-02-21 04:51:39 +0000
committermat-1 <github@matdoes.dev>2021-02-21 04:51:39 +0000
commit78198ac4812f6f33f412bdc62216567aa08d8199 (patch)
tree9cd238e1f74a77bf149d514fbdc2ce3c8f3261f4 /build
parentd4b71f8dab86e95cd50f808fdbd2155f73e84469 (diff)
downloadskyblock-api-78198ac4812f6f33f412bdc62216567aa08d8199.tar.gz
skyblock-api-78198ac4812f6f33f412bdc62216567aa08d8199.tar.bz2
skyblock-api-78198ac4812f6f33f412bdc62216567aa08d8199.zip
Compiled TS into JS
Diffstat (limited to 'build')
-rw-r--r--build/cleaners/skyblock/member.js8
-rw-r--r--build/hypixel.js3
-rw-r--r--build/hypixelCached.js20
-rw-r--r--build/index.js2
4 files changed, 20 insertions, 13 deletions
diff --git a/build/cleaners/skyblock/member.js b/build/cleaners/skyblock/member.js
index 0f2e048..8b922a5 100644
--- a/build/cleaners/skyblock/member.js
+++ b/build/cleaners/skyblock/member.js
@@ -35,8 +35,8 @@ async function cleanSkyBlockProfileMemberResponseBasic(member, included = null)
return {
uuid: member.uuid,
username: player.username,
- last_save: member.last_save,
- first_join: member.first_join,
+ last_save: member.last_save / 1000,
+ first_join: member.first_join / 1000,
rank: player.rank
};
}
@@ -49,8 +49,8 @@ async function cleanSkyBlockProfileMemberResponse(member, included = null) {
return {
uuid: member.uuid,
username: player.username,
- last_save: member.last_save,
- first_join: member.first_join,
+ last_save: member.last_save / 1000,
+ first_join: member.first_join / 1000,
rank: player.rank,
purse: member.coin_purse,
stats: stats_1.cleanProfileStats(member),
diff --git a/build/hypixel.js b/build/hypixel.js
index ace7540..6e6b8b6 100644
--- a/build/hypixel.js
+++ b/build/hypixel.js
@@ -28,6 +28,7 @@ const hypixelApi_1 = require("./hypixelApi");
const cached = __importStar(require("./hypixelCached"));
const profile_1 = require("./cleaners/skyblock/profile");
const profiles_1 = require("./cleaners/skyblock/profiles");
+const _1 = require(".");
// the interval at which the "last_save" parameter updates in the hypixel api, this is 3 minutes
exports.saveInterval = 60 * 3 * 1000;
// the highest level a minion can be
@@ -65,6 +66,8 @@ async function fetchUser({ user, uuid, username }, included = ['player']) {
}
if (!uuid) {
// the user doesn't exist.
+ if (_1.debug)
+ console.log('error:', user, 'doesnt exist');
return null;
}
const includePlayers = included.includes('player');
diff --git a/build/hypixelCached.js b/build/hypixelCached.js
index 4af0816..2769a42 100644
--- a/build/hypixelCached.js
+++ b/build/hypixelCached.js
@@ -30,8 +30,7 @@ const node_cache_1 = __importDefault(require("node-cache"));
const mojang = __importStar(require("./mojang"));
const hypixel = __importStar(require("./hypixel"));
const util_1 = require("./util");
-// TODO: put this somewhere else
-const debug = false;
+const _1 = require(".");
// cache usernames for 4 hours
const usernameCache = new node_cache_1.default({
stdTTL: 60 * 60 * 4,
@@ -93,7 +92,7 @@ exports.uuidFromUser = uuidFromUser;
*/
async function usernameFromUser(user) {
if (usernameCache.has(util_1.undashUuid(user))) {
- if (debug)
+ if (_1.debug)
console.log('Cache hit! usernameFromUser', user);
return usernameCache.get(util_1.undashUuid(user));
}
@@ -106,7 +105,7 @@ exports.usernameFromUser = usernameFromUser;
async function fetchPlayer(user) {
const playerUuid = await uuidFromUser(user);
if (playerCache.has(playerUuid)) {
- if (debug)
+ if (_1.debug)
console.log('Cache hit! fetchPlayer', playerUuid);
return playerCache.get(playerUuid);
}
@@ -123,7 +122,7 @@ async function fetchPlayer(user) {
exports.fetchPlayer = fetchPlayer;
async function fetchSkyblockProfiles(playerUuid) {
if (profilesCache.has(playerUuid)) {
- if (debug)
+ if (_1.debug)
console.log('Cache hit! fetchSkyblockProfiles', playerUuid);
return profilesCache.get(playerUuid);
}
@@ -163,7 +162,7 @@ exports.fetchSkyblockProfiles = fetchSkyblockProfiles;
async function fetchBasicProfiles(user) {
const playerUuid = await uuidFromUser(user);
if (basicProfilesCache.has(playerUuid)) {
- if (debug)
+ if (_1.debug)
console.log('Cache hit! fetchBasicProfiles', playerUuid);
return basicProfilesCache.get(playerUuid);
}
@@ -182,8 +181,11 @@ async function fetchBasicProfiles(user) {
*/
async function fetchProfileUuid(user, profile) {
// if a profile wasn't provided, return
- if (!profile)
+ if (!profile) {
+ if (_1.debug)
+ console.log('no profile provided?', user, profile);
return null;
+ }
const profiles = await fetchBasicProfiles(user);
const profileUuid = util_1.undashUuid(profile);
for (const p of profiles) {
@@ -204,7 +206,7 @@ async function fetchProfile(user, profile) {
const profileUuid = await fetchProfileUuid(playerUuid, profile);
if (profileCache.has(profileUuid)) {
// we have the profile cached, return it :)
- if (debug)
+ if (_1.debug)
console.log('Cache hit! fetchProfile', profileUuid);
return profileCache.get(profileUuid);
}
@@ -230,7 +232,7 @@ async function fetchProfileName(user, profile) {
const playerUuid = await uuidFromUser(user);
if (profileNameCache.has(`${playerUuid}.${profileUuid}`)) {
// Return the profile name if it's cached
- if (debug)
+ if (_1.debug)
console.log('Cache hit! fetchProfileName', profileUuid);
return profileNameCache.get(`${playerUuid}.${profileUuid}`);
}
diff --git a/build/index.js b/build/index.js
index 383ea1d..b089351 100644
--- a/build/index.js
+++ b/build/index.js
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
+exports.debug = void 0;
const hypixel_1 = require("./hypixel");
const express_1 = __importDefault(require("express"));
const app = express_1.default();
+exports.debug = false;
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