aboutsummaryrefslogtreecommitdiff
path: root/build/index.js
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-06-02 23:11:00 -0500
committermat <github@matdoes.dev>2021-06-02 23:11:00 -0500
commit2eb6d7658ac0afa45fd8258a68c7640e4c9e372e (patch)
treefb874bbe80994abfe403d15238635ba2bbdfcc2b /build/index.js
parentb479701eada6dc2beb8018e768e109b687a9fc1d (diff)
downloadskyblock-api-2eb6d7658ac0afa45fd8258a68c7640e4c9e372e.tar.gz
skyblock-api-2eb6d7658ac0afa45fd8258a68c7640e4c9e372e.tar.bz2
skyblock-api-2eb6d7658ac0afa45fd8258a68c7640e4c9e372e.zip
actually 404 when something isn't found
Diffstat (limited to 'build/index.js')
-rw-r--r--build/index.js16
1 files changed, 12 insertions, 4 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) => {