aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts44
1 files changed, 32 insertions, 12 deletions
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) => {