aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/index.ts b/src/index.ts
index 176b73f..de3e21f 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -35,13 +35,18 @@ app.get('/', async(req, res) => {
})
app.get('/player/:user', async(req, res) => {
- res.json(
- await fetchUser(
- { user: req.params.user },
- [req.query.basic as string === 'true' ? undefined : 'profiles', 'player'],
- req.query.customization as string === 'true'
+ try {
+ res.json(
+ await fetchUser(
+ { user: req.params.user },
+ [req.query.basic as string === 'true' ? undefined : 'profiles', 'player'],
+ req.query.customization as string === 'true'
+ )
)
- )
+ } catch (err) {
+ console.error(err)
+ res.json({ 'error': true })
+ }
})
app.get('/discord/:id', async(req, res) => {
@@ -51,9 +56,14 @@ app.get('/discord/:id', async(req, res) => {
})
app.get('/player/:user/:profile', async(req, res) => {
- res.json(
- await fetchMemberProfile(req.params.user, req.params.profile, req.query.customization as string === 'true')
- )
+ try {
+ res.json(
+ await fetchMemberProfile(req.params.user, req.params.profile, req.query.customization as string === 'true')
+ )
+ } catch (err) {
+ console.error(err)
+ res.json({ 'error': true })
+ }
})
app.get('/player/:user/:profile/leaderboards', async(req, res) => {