aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/cleaners/player.js2
-rw-r--r--build/cleaners/skyblock/member.js10
-rw-r--r--build/cleaners/skyblock/minions.js2
-rw-r--r--build/cleaners/skyblock/profile.js2
-rw-r--r--build/cleaners/skyblock/stats.js1
-rw-r--r--build/constants.js2
-rw-r--r--build/database.js29
-rw-r--r--build/discord.js4
-rw-r--r--build/hypixel.js41
-rw-r--r--build/hypixelApi.js7
-rw-r--r--build/hypixelCached.js46
-rw-r--r--build/index.js9
12 files changed, 105 insertions, 50 deletions
diff --git a/build/cleaners/player.js b/build/cleaners/player.js
index dadb129..42c76b8 100644
--- a/build/cleaners/player.js
+++ b/build/cleaners/player.js
@@ -9,7 +9,7 @@ async function cleanPlayerResponse(data) {
var _a, _b;
// Cleans up a 'player' api response
if (!data)
- return; // bruh
+ return null; // bruh
return {
uuid: util_1.undashUuid(data.uuid),
username: data.displayname,
diff --git a/build/cleaners/skyblock/member.js b/build/cleaners/skyblock/member.js
index 8e72be8..cc66488 100644
--- a/build/cleaners/skyblock/member.js
+++ b/build/cleaners/skyblock/member.js
@@ -31,8 +31,10 @@ const zones_1 = require("./zones");
const skills_1 = require("./skills");
const cached = __importStar(require("../../hypixelCached"));
const constants = __importStar(require("../../constants"));
-async function cleanSkyBlockProfileMemberResponseBasic(member, included = null) {
+async function cleanSkyBlockProfileMemberResponseBasic(member) {
const player = await cached.fetchPlayer(member.uuid);
+ if (!player)
+ return null;
return {
uuid: member.uuid,
username: player.username,
@@ -43,13 +45,13 @@ async function cleanSkyBlockProfileMemberResponseBasic(member, included = null)
}
exports.cleanSkyBlockProfileMemberResponseBasic = cleanSkyBlockProfileMemberResponseBasic;
/** Cleans up a member (from skyblock/profile) */
-async function cleanSkyBlockProfileMemberResponse(member, included = null) {
+async function cleanSkyBlockProfileMemberResponse(member, included = undefined) {
var _a;
// profiles.members[]
- const inventoriesIncluded = included === null || included.includes('inventories');
+ const inventoriesIncluded = included === undefined || included.includes('inventories');
const player = await cached.fetchPlayer(member.uuid);
if (!player)
- return;
+ return null;
const fairySouls = fairysouls_1.cleanFairySouls(member);
const { max_fairy_souls: maxFairySouls } = await constants.fetchConstantValues();
if (fairySouls.total > (maxFairySouls !== null && maxFairySouls !== void 0 ? maxFairySouls : 0))
diff --git a/build/cleaners/skyblock/minions.js b/build/cleaners/skyblock/minions.js
index fae3c96..d2bfc41 100644
--- a/build/cleaners/skyblock/minions.js
+++ b/build/cleaners/skyblock/minions.js
@@ -89,7 +89,7 @@ function combineMinionArrays(minions) {
// This should never happen, but in case the length of `minion.levels` is longer than
// `matchingMinionReference.levels`, then it should be extended to be equal length
while (matchingMinionReference.levels.length < minion.levels.length)
- matchingMinionReference.levels.push(null);
+ matchingMinionReference.levels.push(false);
for (let i = 0; i < minion.levels.length; i++) {
if (minion.levels[i])
matchingMinionReference.levels[i] = true;
diff --git a/build/cleaners/skyblock/profile.js b/build/cleaners/skyblock/profile.js
index 45ef57b..da988cc 100644
--- a/build/cleaners/skyblock/profile.js
+++ b/build/cleaners/skyblock/profile.js
@@ -34,7 +34,7 @@ async function cleanSkyblockProfileResponseLighter(data) {
// we pass an empty array to make it not check stats
promises.push(member_1.cleanSkyBlockProfileMemberResponseBasic(memberRaw));
}
- const cleanedMembers = await Promise.all(promises);
+ const cleanedMembers = (await Promise.all(promises)).filter(m => m);
return {
uuid: data.profile_id,
name: data.cute_name,
diff --git a/build/cleaners/skyblock/stats.js b/build/cleaners/skyblock/stats.js
index 482771c..4ca671b 100644
--- a/build/cleaners/skyblock/stats.js
+++ b/build/cleaners/skyblock/stats.js
@@ -74,6 +74,7 @@ function getStatUnit(name) {
return unitName;
}
}
+ return null;
}
exports.getStatUnit = getStatUnit;
function cleanProfileStats(data) {
diff --git a/build/constants.js b/build/constants.js
index 22327c5..414a6c5 100644
--- a/build/constants.js
+++ b/build/constants.js
@@ -57,7 +57,7 @@ async function fetchGithubApi(method, route, headers, json) {
console.debug('fetching github api', method, route);
const data = await node_fetch_1.default(githubApiBase + route, {
agent: () => httpsAgent,
- body: json ? JSON.stringify(json) : null,
+ body: json ? JSON.stringify(json) : undefined,
method,
headers: Object.assign({
'Authorization': `token ${process.env.github_token}`
diff --git a/build/database.js b/build/database.js
index eb5a63f..c34222d 100644
--- a/build/database.js
+++ b/build/database.js
@@ -137,9 +137,11 @@ async function fetchAllLeaderboardsCategorized() {
const categorizedLeaderboards = {};
for (const leaderboard of [...memberLeaderboardAttributes, ...profileLeaderboardAttributes]) {
const { category } = stats_1.categorizeStat(leaderboard);
- if (!categorizedLeaderboards[category])
- categorizedLeaderboards[category] = [];
- categorizedLeaderboards[category].push(leaderboard);
+ if (category) {
+ if (!categorizedLeaderboards[category])
+ categorizedLeaderboards[category] = [];
+ categorizedLeaderboards[category].push(leaderboard);
+ }
}
// move misc to end by removing and readding it
const misc = categorizedLeaderboards.misc;
@@ -277,8 +279,9 @@ async function fetchMemberLeaderboard(name) {
var _a;
const leaderboardRaw = await fetchMemberLeaderboardRaw(name);
const fetchLeaderboardPlayer = async (i) => {
+ const player = await cached.fetchBasicPlayer(i.uuid);
return {
- player: await cached.fetchBasicPlayer(i.uuid),
+ player,
profileUuid: i.profile,
value: i.value
};
@@ -301,8 +304,11 @@ async function fetchProfileLeaderboard(name) {
const leaderboardRaw = await fetchProfileLeaderboardRaw(name);
const fetchLeaderboardProfile = async (i) => {
const players = [];
- for (const playerUuid of i.players)
- players.push(await cached.fetchBasicPlayer(playerUuid));
+ for (const playerUuid of i.players) {
+ const player = await cached.fetchBasicPlayer(playerUuid);
+ if (player)
+ players.push(player);
+ }
return {
players: players,
profileUuid: i.uuid,
@@ -340,7 +346,11 @@ exports.fetchLeaderboard = fetchLeaderboard;
async function fetchMemberLeaderboardSpots(player, profile) {
var _a;
const fullProfile = await cached.fetchProfile(player, profile);
+ if (!fullProfile)
+ return null;
const fullMember = fullProfile.members.find(m => m.username.toLowerCase() === player.toLowerCase() || m.uuid === player);
+ if (!fullMember)
+ return null;
// update the leaderboard positions for the member
await updateDatabaseMember(fullMember, fullProfile);
const applicableAttributes = await getApplicableMemberLeaderboardAttributes(fullMember);
@@ -404,8 +414,8 @@ async function getApplicableProfileLeaderboardAttributes(profile) {
}
let leaderboardsCount = Object.keys(applicableAttributes).length;
const leaderboardsCountRequirement = await getLeaderboardRequirement('leaderboards_count', 'member');
- if ((leaderboardsCountRequirement === null)
- || (leaderboardsCount > leaderboardsCountRequirement)) {
+ if (leaderboardsCountRequirement === null
+ || leaderboardsCount > leaderboardsCountRequirement) {
applicableAttributes['leaderboards_count'] = leaderboardsCount;
}
return applicableAttributes;
@@ -423,7 +433,8 @@ async function updateDatabaseMember(member, profile) {
recentlyUpdated.set(profile.uuid + member.uuid, true);
if (_1.debug)
console.debug('adding member to leaderboards', member.username);
- await constants.addStats(Object.keys(member.rawHypixelStats));
+ if (member.rawHypixelStats)
+ 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));
diff --git a/build/discord.js b/build/discord.js
index a92521a..ba9f3eb 100644
--- a/build/discord.js
+++ b/build/discord.js
@@ -13,6 +13,10 @@ const httpsAgent = new https_1.Agent({
async function exchangeCode(redirectUri, code) {
const API_ENDPOINT = 'https://discord.com/api/v6';
const CLIENT_SECRET = process.env.discord_client_secret;
+ if (!CLIENT_SECRET) {
+ console.error('discord_client_secret isn\'t in env, couldn\'t login with discord');
+ return null;
+ }
const data = {
'client_id': DISCORD_CLIENT_ID,
'client_secret': CLIENT_SECRET,
diff --git a/build/hypixel.js b/build/hypixel.js
index 8750170..414139e 100644
--- a/build/hypixel.js
+++ b/build/hypixel.js
@@ -62,22 +62,25 @@ async function cleanResponse({ path, data }, options) {
* used inclusions: player, profiles
*/
async function fetchUser({ user, uuid, username }, included = ['player'], customization) {
+ var _a, _b;
if (!uuid) {
// If the uuid isn't provided, get it
- uuid = await cached.uuidFromUser(user || username);
+ if (!username && !user)
+ return null;
+ uuid = await cached.uuidFromUser((user !== null && user !== void 0 ? user : username));
}
- const websiteAccountPromise = customization ? database_1.fetchAccount(uuid) : null;
if (!uuid) {
// the user doesn't exist.
if (_1.debug)
console.debug('error:', user, 'doesnt exist');
return null;
}
+ const websiteAccountPromise = customization ? database_1.fetchAccount(uuid) : null;
const includePlayers = included.includes('player');
const includeProfiles = included.includes('profiles');
let profilesData;
let basicProfilesData;
- let playerData;
+ let playerData = null;
if (includePlayers) {
playerData = await cached.fetchPlayer(uuid);
// if not including profiles, include lightweight profiles just in case
@@ -86,28 +89,26 @@ async function fetchUser({ user, uuid, username }, included = ['player'], custom
if (playerData)
delete playerData.profiles;
}
- if (includeProfiles) {
+ if (includeProfiles)
profilesData = await cached.fetchSkyblockProfiles(uuid);
- }
- let activeProfile = null;
+ let activeProfile;
let lastOnline = 0;
if (includeProfiles) {
for (const profile of profilesData) {
- const member = profile.members.find(member => member.uuid === uuid);
- if (member.last_save > lastOnline) {
+ const member = (_a = profile.members) === null || _a === void 0 ? void 0 : _a.find(member => member.uuid === uuid);
+ if (member && member.last_save > lastOnline) {
lastOnline = member.last_save;
activeProfile = profile;
}
}
}
- let websiteAccount = undefined;
- if (websiteAccountPromise) {
+ let websiteAccount = null;
+ if (websiteAccountPromise)
websiteAccount = await websiteAccountPromise;
- }
return {
- player: playerData !== null && playerData !== void 0 ? playerData : null,
+ player: playerData,
profiles: profilesData !== null && profilesData !== void 0 ? profilesData : basicProfilesData,
- activeProfile: includeProfiles ? activeProfile === null || activeProfile === void 0 ? void 0 : activeProfile.uuid : undefined,
+ activeProfile: includeProfiles ? (_b = activeProfile) === null || _b === void 0 ? void 0 : _b.uuid : undefined,
online: includeProfiles ? lastOnline > (Date.now() - exports.saveInterval) : undefined,
customization: websiteAccount === null || websiteAccount === void 0 ? void 0 : websiteAccount.customization
};
@@ -123,7 +124,7 @@ exports.fetchUser = fetchUser;
async function fetchMemberProfile(user, profile, customization) {
const playerUuid = await cached.uuidFromUser(user);
if (!playerUuid)
- return;
+ return null;
// we don't await the promise immediately so it can load while we do other stuff
const websiteAccountPromise = customization ? database_1.fetchAccount(playerUuid) : null;
const profileUuid = await cached.fetchProfileUuid(user, profile);
@@ -133,8 +134,12 @@ async function fetchMemberProfile(user, profile, customization) {
if (!playerUuid)
return null;
const player = await cached.fetchPlayer(playerUuid);
+ if (!player)
+ return null; // this should never happen, but if it does just return null
const cleanProfile = await cached.fetchProfile(playerUuid, profileUuid);
const member = cleanProfile.members.find(m => m.uuid === playerUuid);
+ if (!member)
+ return null; // this should never happen, but if it does just return null
// remove unnecessary member data
const simpleMembers = cleanProfile.members.map(m => {
return {
@@ -146,7 +151,7 @@ async function fetchMemberProfile(user, profile, customization) {
};
});
cleanProfile.members = simpleMembers;
- let websiteAccount = undefined;
+ let websiteAccount = null;
if (websiteAccountPromise)
websiteAccount = await websiteAccountPromise;
return {
@@ -172,7 +177,7 @@ async function fetchMemberProfileUncached(playerUuid, profileUuid) {
const profile = await sendCleanApiRequest({
path: 'skyblock/profile',
args: { profile: profileUuid }
- }, null, { mainMemberUuid: playerUuid });
+ }, undefined, { mainMemberUuid: playerUuid });
// queue updating the leaderboard positions for the member, eventually
for (const member of profile.members)
database_1.queueUpdateDatabaseMember(member, profile);
@@ -189,7 +194,7 @@ async function fetchBasicProfileFromUuidUncached(profileUuid) {
const profile = await sendCleanApiRequest({
path: 'skyblock/profile',
args: { profile: profileUuid }
- }, null, { basic: true });
+ }, undefined, { basic: true });
return profile;
}
exports.fetchBasicProfileFromUuidUncached = fetchBasicProfileFromUuidUncached;
@@ -199,7 +204,7 @@ async function fetchMemberProfilesUncached(playerUuid) {
args: {
uuid: playerUuid
}
- }, null, {
+ }, undefined, {
// only the inventories for the main player are generated, this is for optimization purposes
mainMemberUuid: playerUuid
});
diff --git a/build/hypixelApi.js b/build/hypixelApi.js
index df6d426..a35dd64 100644
--- a/build/hypixelApi.js
+++ b/build/hypixelApi.js
@@ -60,6 +60,7 @@ 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
+ var _a, _b, _c;
if (key)
// If there's an api key, add it to the arguments
args.key = key;
@@ -84,9 +85,9 @@ async function sendApiRequest({ path, key, args }) {
if (fetchResponse.headers.get('ratelimit-limit'))
// remember how many uses it has
apiKeyUsage[key] = {
- remaining: parseInt(fetchResponse.headers.get('ratelimit-remaining')),
- limit: parseInt(fetchResponse.headers.get('ratelimit-limit')),
- reset: Date.now() + parseInt(fetchResponse.headers.get('ratelimit-reset')) * 1000
+ remaining: parseInt((_a = fetchResponse.headers.get('ratelimit-remaining')) !== null && _a !== void 0 ? _a : '0'),
+ limit: parseInt((_b = fetchResponse.headers.get('ratelimit-limit')) !== null && _b !== void 0 ? _b : '0'),
+ reset: Date.now() + parseInt((_c = fetchResponse.headers.get('ratelimit-reset')) !== null && _c !== void 0 ? _c : '0') * 1000
};
if (fetchJsonParsed.throttle) {
if (apiKeyUsage[key])
diff --git a/build/hypixelCached.js b/build/hypixelCached.js
index d732f2d..d54aa68 100644
--- a/build/hypixelCached.js
+++ b/build/hypixelCached.js
@@ -95,7 +95,7 @@ async function uuidFromUser(user) {
const username = exports.usernameCache.get(util_1.undashUuid(user));
// sometimes the username will be null, return that
if (username === null)
- return null;
+ return undefined;
// if it has .then, then that means its a waitForCacheSet promise. This is done to prevent requests made while it is already requesting
if (username.then) {
const { key: uuid, value: _username } = await username;
@@ -134,14 +134,17 @@ exports.uuidFromUser = uuidFromUser;
* @param user A user can be either a uuid or a username
*/
async function usernameFromUser(user) {
+ var _a;
if (exports.usernameCache.has(util_1.undashUuid(user))) {
if (_1.debug)
console.debug('Cache hit! usernameFromUser', user);
- return exports.usernameCache.get(util_1.undashUuid(user));
+ return (_a = exports.usernameCache.get(util_1.undashUuid(user))) !== null && _a !== void 0 ? _a : null;
}
if (_1.debug)
console.debug('Cache miss: usernameFromUser', user);
let { uuid, username } = await mojang.profileFromUser(user);
+ if (!uuid)
+ return null;
uuid = util_1.undashUuid(uuid);
exports.usernameCache.set(uuid, username);
return username;
@@ -150,6 +153,8 @@ exports.usernameFromUser = usernameFromUser;
let fetchingPlayers = new Set();
async function fetchPlayer(user) {
const playerUuid = await uuidFromUser(user);
+ if (!playerUuid)
+ return null;
if (exports.playerCache.has(playerUuid))
return exports.playerCache.get(playerUuid);
// if it's already in the process of fetching, check every 100ms until it's not fetching the player anymore and fetch it again, since it'll be cached now
@@ -166,7 +171,7 @@ async function fetchPlayer(user) {
});
fetchingPlayers.delete(playerUuid);
if (!cleanPlayer)
- return;
+ return null;
// clone in case it gets modified somehow later
exports.playerCache.set(playerUuid, cleanPlayer);
exports.usernameCache.set(playerUuid, cleanPlayer.username);
@@ -179,16 +184,21 @@ exports.fetchPlayer = fetchPlayer;
/** Fetch a player without their profiles. This is heavily cached. */
async function fetchBasicPlayer(user) {
const playerUuid = await uuidFromUser(user);
+ if (!playerUuid)
+ return null;
if (exports.basicPlayerCache.has(playerUuid))
return exports.basicPlayerCache.get(playerUuid);
const player = await fetchPlayer(playerUuid);
- if (!player)
+ if (!player) {
console.debug('no player? this should never happen', user, playerUuid);
+ return null;
+ }
delete player.profiles;
return player;
}
exports.fetchBasicPlayer = fetchBasicPlayer;
async function fetchSkyblockProfiles(playerUuid) {
+ var _a;
if (exports.profilesCache.has(playerUuid)) {
if (_1.debug)
console.debug('Cache hit! fetchSkyblockProfiles', playerUuid);
@@ -203,7 +213,7 @@ async function fetchSkyblockProfiles(playerUuid) {
const basicProfile = {
name: profile.name,
uuid: profile.uuid,
- members: profile.members.map(m => {
+ members: (_a = profile.members) === null || _a === void 0 ? void 0 : _a.map(m => {
return {
uuid: m.uuid,
username: m.username,
@@ -224,7 +234,7 @@ exports.fetchSkyblockProfiles = fetchSkyblockProfiles;
async function fetchBasicProfiles(user) {
const playerUuid = await uuidFromUser(user);
if (!playerUuid)
- return; // invalid player, just return
+ return null; // invalid player, just return
if (exports.basicProfilesCache.has(playerUuid)) {
if (_1.debug)
console.debug('Cache hit! fetchBasicProfiles', playerUuid);
@@ -239,6 +249,8 @@ async function fetchBasicProfiles(user) {
}
const profiles = player.profiles;
exports.basicProfilesCache.set(playerUuid, profiles);
+ if (!profiles)
+ return null;
// cache the profile names and uuids to profileNameCache because we can
for (const profile of profiles)
exports.profileNameCache.set(`${playerUuid}.${profile.uuid}`, profile.name);
@@ -250,6 +262,7 @@ async function fetchBasicProfiles(user) {
* @param profile A profile name or profile uuid
*/
async function fetchProfileUuid(user, profile) {
+ var _a;
// if a profile wasn't provided, return
if (!profile) {
if (_1.debug)
@@ -260,10 +273,10 @@ async function fetchProfileUuid(user, profile) {
console.debug('Cache miss: fetchProfileUuid', user, profile);
const profiles = await fetchBasicProfiles(user);
if (!profiles)
- return; // user probably doesnt exist
+ return null; // user probably doesnt exist
const profileUuid = util_1.undashUuid(profile);
for (const p of profiles) {
- if (p.name.toLowerCase() === profileUuid.toLowerCase())
+ if (((_a = p.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === profileUuid.toLowerCase())
return util_1.undashUuid(p.uuid);
else if (util_1.undashUuid(p.uuid) === util_1.undashUuid(profileUuid))
return util_1.undashUuid(p.uuid);
@@ -278,6 +291,8 @@ exports.fetchProfileUuid = fetchProfileUuid;
*/
async function fetchProfile(user, profile) {
const playerUuid = await uuidFromUser(user);
+ if (!playerUuid)
+ return null;
const profileUuid = await fetchProfileUuid(playerUuid, profile);
if (!profileUuid)
return null;
@@ -290,6 +305,8 @@ async function fetchProfile(user, profile) {
if (_1.debug)
console.debug('Cache miss: fetchProfile', user, profile);
const profileName = await fetchProfileName(user, profile);
+ if (!profileName)
+ return null; // uhh this should never happen but if it does just return null
const cleanProfile = await hypixel.fetchMemberProfileUncached(playerUuid, profileUuid);
// we know the name from fetchProfileName, so set it here
cleanProfile.name = profileName;
@@ -307,6 +324,8 @@ async function fetchBasicProfileFromUuid(profileUuid) {
if (_1.debug)
console.debug('Cache hit! fetchBasicProfileFromUuid', profileUuid);
const profile = exports.profileCache.get(profileUuid);
+ if (!profile)
+ return undefined;
return {
uuid: profile.uuid,
members: profile.members.map(m => ({
@@ -329,24 +348,29 @@ exports.fetchBasicProfileFromUuid = fetchBasicProfileFromUuid;
* @param profile A profile uuid or name
*/
async function fetchProfileName(user, profile) {
+ var _a, _b;
// we're fetching the profile and player uuid again in case we were given a name, but it's cached so it's not much of a problem
const profileUuid = await fetchProfileUuid(user, profile);
if (!profileUuid)
return null;
const playerUuid = await uuidFromUser(user);
+ if (!playerUuid)
+ return null;
if (exports.profileNameCache.has(`${playerUuid}.${profileUuid}`)) {
// Return the profile name if it's cached
if (_1.debug)
console.debug('Cache hit! fetchProfileName', profileUuid);
- return exports.profileNameCache.get(`${playerUuid}.${profileUuid}`);
+ return (_a = exports.profileNameCache.get(`${playerUuid}.${profileUuid}`)) !== null && _a !== void 0 ? _a : null;
}
if (_1.debug)
console.debug('Cache miss: fetchProfileName', user, profile);
const basicProfiles = await fetchBasicProfiles(playerUuid);
- let profileName;
+ if (!basicProfiles)
+ return null;
+ let profileName = null;
for (const basicProfile of basicProfiles)
if (basicProfile.uuid === playerUuid)
- profileName = basicProfile.name;
+ profileName = (_b = basicProfile.name) !== null && _b !== void 0 ? _b : null;
exports.profileNameCache.set(`${playerUuid}.${profileUuid}`, profileName);
return profileName;
}
diff --git a/build/index.js b/build/index.js
index 736b137..8bb2040 100644
--- a/build/index.js
+++ b/build/index.js
@@ -136,7 +136,12 @@ app.get('/constants', async (req, res) => {
app.post('/accounts/createsession', async (req, res) => {
try {
const { code } = req.body;
- const { access_token: accessToken, refresh_token: refreshToken } = await discord.exchangeCode(`${mainSiteUrl}/loggedin`, code);
+ const codeExchange = await discord.exchangeCode(`${mainSiteUrl}/loggedin`, code);
+ if (!codeExchange) {
+ res.json({ ok: false, error: 'discord_client_secret isn\'t in env' });
+ return;
+ }
+ const { access_token: accessToken, refresh_token: refreshToken } = codeExchange;
if (!accessToken)
// access token is invalid :(
return res.json({ ok: false });
@@ -152,6 +157,8 @@ app.post('/accounts/session', async (req, res) => {
try {
const { uuid } = req.body;
const session = await database_1.fetchSession(uuid);
+ if (!session)
+ return res.json({ ok: false });
const account = await database_1.fetchAccountFromDiscord(session.discord_user.id);
res.json({ session, account });
}