From 849e87a468dc6057738b33e0d5dae55576ffc399 Mon Sep 17 00:00:00 2001 From: Sanjay Date: Thu, 12 Oct 2023 12:03:33 -0700 Subject: [PATCH] fix: fix potential crash (#121) --- src/app.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app.ts b/src/app.ts index 5d591c1e8..de79c0e8c 100644 --- a/src/app.ts +++ b/src/app.ts @@ -75,17 +75,17 @@ app.get('/transfers', async (req, res) => { }); app.get('/transfers/current', async (req, res) => { - let name: string | undefined; - if (req.query.fid) { - name = await getCurrentUsername(parseInt(req.query.fid.toString()), db); - } else if (req.query.name) { - name = req.query.name.toString(); - } - if (!name || name === '') { - res.status(404).send({ error: 'Could not resolve current name' }).end(); - return; - } try { + let name: string | undefined; + if (req.query.fid) { + name = await getCurrentUsername(parseInt(req.query.fid.toString()), db); + } else if (req.query.name) { + name = req.query.name.toString(); + } + if (!name || name === '') { + res.status(404).send({ error: 'Could not resolve current name' }).end(); + return; + } const transfer = await getLatestTransfer(name, db); if (!transfer || transfer.to === 0) { res.status(404).send({ error: 'No transfer found' }).end();