diff options
author | mat <github@matdoes.dev> | 2021-06-02 23:11:00 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2021-06-02 23:11:00 -0500 |
commit | 2eb6d7658ac0afa45fd8258a68c7640e4c9e372e (patch) | |
tree | fb874bbe80994abfe403d15238635ba2bbdfcc2b /build | |
parent | b479701eada6dc2beb8018e768e109b687a9fc1d (diff) | |
download | skyblock-api-2eb6d7658ac0afa45fd8258a68c7640e4c9e372e.tar.gz skyblock-api-2eb6d7658ac0afa45fd8258a68c7640e4c9e372e.tar.bz2 skyblock-api-2eb6d7658ac0afa45fd8258a68c7640e4c9e372e.zip |
actually 404 when something isn't found
Diffstat (limited to 'build')
-rw-r--r-- | build/index.js | 16 | ||||
-rw-r--r-- | build/mojang.js | 1 |
2 files changed, 12 insertions, 5 deletions
diff --git a/build/index.js b/build/index.js index 577c1ac..736b137 100644 --- a/build/index.js +++ b/build/index.js @@ -64,11 +64,15 @@ app.get('/', async (req, res) => { }); app.get('/player/:user', async (req, res) => { try { - res.json(await hypixel_1.fetchUser({ user: req.params.user }, [req.query.basic === 'true' ? undefined : 'profiles', 'player'], req.query.customization === 'true')); + const user = await hypixel_1.fetchUser({ user: req.params.user }, [req.query.basic === 'true' ? undefined : 'profiles', 'player'], req.query.customization === 'true'); + if (user) + res.json(user); + else + res.status(404).json({ error: true }); } catch (err) { console.error(err); - res.json({ 'error': true }); + res.json({ error: true }); } }); app.get('/discord/:id', async (req, res) => { @@ -82,11 +86,15 @@ app.get('/discord/:id', async (req, res) => { }); app.get('/player/:user/:profile', async (req, res) => { try { - res.json(await hypixel_1.fetchMemberProfile(req.params.user, req.params.profile, req.query.customization === 'true')); + const profile = await hypixel_1.fetchMemberProfile(req.params.user, req.params.profile, req.query.customization === 'true'); + if (profile) + res.json(profile); + else + res.status(404).json({ error: true }); } catch (err) { console.error(err); - res.json({ 'error': true }); + res.json({ error: true }); } }); app.get('/player/:user/:profile/leaderboards', async (req, res) => { diff --git a/build/mojang.js b/build/mojang.js index e5b6ee6..3ad8d5e 100644 --- a/build/mojang.js +++ b/build/mojang.js @@ -88,7 +88,6 @@ async function profileFromUsernameAlternative(username) { catch { return { uuid: null, username: null }; } - console.log('aight ashcon returned', data); return { uuid: util_1.undashUuid(data.uuid), username: data.username |