Skip to content

Commit

Permalink
ANON-212 - Empty array if no relay found in batch search (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
yumirkov authored Oct 17, 2024
1 parent 474248d commit f90b8ae
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,18 @@ app.get('/relays', async (req, res) => {
const foundRelays = details.relays.filter((relay: { fingerprint: string; }) =>
fingerprints.includes(relay.fingerprint)
);
console.log('Found relays:', foundRelays);

if (foundRelays.length > 0) {
const relays = foundRelays.map((foundRelay : any) => ({
nickname: foundRelay.nickname,
fingerprint: foundRelay.fingerprint,
running: foundRelay.running,
consensus_weight: foundRelay.consensus_weight,
observed_bandwidth: foundRelay.observed_bandwidth,
measured: foundRelay.measured
}));
console.log('Result relays:', relays);
return res.json(relays);
} else {
console.log("No relays found");
return res.status(404).send('No relays found');
}
console.log('Found relays:', foundRelays.length);

const relays = foundRelays.map((foundRelay : any) => ({
nickname: foundRelay.nickname,
fingerprint: foundRelay.fingerprint,
running: foundRelay.running,
consensus_weight: foundRelay.consensus_weight,
observed_bandwidth: foundRelay.observed_bandwidth,
measured: foundRelay.measured
}));
console.log('Result relays:', relays);
return res.json(relays);
} catch (error) {
console.error(error);
res.status(500).send('Error querying Onionoo');
Expand Down

0 comments on commit f90b8ae

Please sign in to comment.