aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/index.ts26
-rw-r--r--src/mojang.ts1
2 files changed, 15 insertions, 12 deletions
diff --git a/src/index.ts b/src/index.ts
index 489ef52..4f4ad00 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -46,16 +46,18 @@ app.get('/', async(req, res) => {
app.get('/player/:user', async(req, res) => {
try {
- res.json(
- await fetchUser(
- { user: req.params.user },
- [req.query.basic as string === 'true' ? undefined : 'profiles', 'player'],
- req.query.customization as string === 'true'
- )
+ const user = await fetchUser(
+ { user: req.params.user },
+ [req.query.basic as string === 'true' ? undefined : 'profiles', 'player'],
+ req.query.customization as string === '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 })
}
})
@@ -72,12 +74,14 @@ app.get('/discord/:id', async(req, res) => {
app.get('/player/:user/:profile', async(req, res) => {
try {
- res.json(
- await fetchMemberProfile(req.params.user, req.params.profile, req.query.customization as string === 'true')
- )
+ const profile = await fetchMemberProfile(req.params.user, req.params.profile, req.query.customization as string === '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 })
}
})
diff --git a/src/mojang.ts b/src/mojang.ts
index 2560c77..055809a 100644
--- a/src/mojang.ts
+++ b/src/mojang.ts
@@ -105,7 +105,6 @@ export async function profileFromUsernameAlternative(username: string): Promise<
} catch {
return { uuid: null, username: null }
}
- console.log('aight ashcon returned', data)
return {
uuid: undashUuid(data.uuid),
username: data.username