Skip to content

Commit

Permalink
fix: fix potential crash (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayprabhu authored Oct 12, 2023
1 parent c11828c commit 849e87a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 849e87a

Please sign in to comment.