diff options
author | mat <github@matdoes.dev> | 2021-05-29 21:39:01 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2021-05-29 21:39:01 -0500 |
commit | 364eab6e95b722f4293110e5fa5063c6b15ad9ef (patch) | |
tree | cb00bd8b0ab946f9023f6e7ee7e2b56aa2fd468a | |
parent | 2a7c5f1ac74381e27e8bf00599b88dcb02f4fe28 (diff) | |
download | skyblock-api-364eab6e95b722f4293110e5fa5063c6b15ad9ef.tar.gz skyblock-api-364eab6e95b722f4293110e5fa5063c6b15ad9ef.tar.bz2 skyblock-api-364eab6e95b722f4293110e5fa5063c6b15ad9ef.zip |
add more try catches
-rw-r--r-- | build/index.js | 32 | ||||
-rw-r--r-- | src/index.ts | 44 |
2 files changed, 60 insertions, 16 deletions
diff --git a/build/index.js b/build/index.js index 4644fed..70d11d0 100644 --- a/build/index.js +++ b/build/index.js @@ -70,7 +70,13 @@ app.get('/player/:user', async (req, res) => { } }); app.get('/discord/:id', async (req, res) => { - res.json(await database_1.fetchAccountFromDiscord(req.params.id)); + try { + res.json(await database_1.fetchAccountFromDiscord(req.params.id)); + } + catch (err) { + console.error(err); + res.json({ ok: false }); + } }); app.get('/player/:user/:profile', async (req, res) => { try { @@ -82,7 +88,13 @@ app.get('/player/:user/:profile', async (req, res) => { } }); app.get('/player/:user/:profile/leaderboards', async (req, res) => { - res.json(await database_1.fetchMemberLeaderboardSpots(req.params.user, req.params.profile)); + try { + res.json(await database_1.fetchMemberLeaderboardSpots(req.params.user, req.params.profile)); + } + catch (err) { + console.error(err); + res.json({ ok: false }); + } }); app.get('/leaderboard/:name', async (req, res) => { try { @@ -94,10 +106,22 @@ app.get('/leaderboard/:name', async (req, res) => { } }); app.get('/leaderboards', async (req, res) => { - res.json(await database_1.fetchAllLeaderboardsCategorized()); + try { + res.json(await database_1.fetchAllLeaderboardsCategorized()); + } + catch (err) { + console.error(err); + res.json({ ok: false }); + } }); app.get('/constants', async (req, res) => { - res.json(await constants.fetchConstantValues()); + try { + res.json(await constants.fetchConstantValues()); + } + catch (err) { + console.error(err); + res.json({ ok: false }); + } }); app.post('/accounts/createsession', async (req, res) => { try { diff --git a/src/index.ts b/src/index.ts index 952c2aa..fe6ea90 100644 --- a/src/index.ts +++ b/src/index.ts @@ -57,9 +57,14 @@ app.get('/player/:user', async(req, res) => { }) app.get('/discord/:id', async(req, res) => { - res.json( - await fetchAccountFromDiscord(req.params.id) - ) + try { + res.json( + await fetchAccountFromDiscord(req.params.id) + ) + } catch (err) { + console.error(err) + res.json({ ok: false }) + } }) app.get('/player/:user/:profile', async(req, res) => { @@ -74,9 +79,14 @@ app.get('/player/:user/:profile', async(req, res) => { }) app.get('/player/:user/:profile/leaderboards', async(req, res) => { - res.json( - await fetchMemberLeaderboardSpots(req.params.user, req.params.profile) - ) + try { + res.json( + await fetchMemberLeaderboardSpots(req.params.user, req.params.profile) + ) + } catch (err) { + console.error(err) + res.json({ ok: false }) + } }) app.get('/leaderboard/:name', async(req, res) => { @@ -91,15 +101,25 @@ app.get('/leaderboard/:name', async(req, res) => { }) app.get('/leaderboards', async(req, res) => { - res.json( - await fetchAllLeaderboardsCategorized() - ) + try { + res.json( + await fetchAllLeaderboardsCategorized() + ) + } catch (err) { + console.error(err) + res.json({ ok: false }) + } }) app.get('/constants', async(req, res) => { - res.json( - await constants.fetchConstantValues() - ) + try { + res.json( + await constants.fetchConstantValues() + ) + } catch (err) { + console.error(err) + res.json({ ok: false }) + } }) app.post('/accounts/createsession', async(req, res) => { |