On not found price id return list of not found ids (#200)
This commit is contained in:
parent
7b9d5b1c22
commit
11e15c96b0
|
@ -105,12 +105,14 @@ export class RestAPI {
|
|||
|
||||
let responseJson = [];
|
||||
|
||||
let notFoundIds: string[] = [];
|
||||
|
||||
for (let id of priceIds) {
|
||||
let latestPriceInfo = this.priceFeedVaaInfo.getLatestPriceInfo(id);
|
||||
|
||||
if (latestPriceInfo === undefined) {
|
||||
res.status(StatusCodes.BAD_REQUEST).send(`Price Feed with id ${id} not found`);
|
||||
return;
|
||||
notFoundIds.push(id);
|
||||
continue;
|
||||
}
|
||||
|
||||
const freshness: DurationInSec = (new Date).getTime() / 1000 - latestPriceInfo.receiveTime;
|
||||
|
@ -119,6 +121,11 @@ export class RestAPI {
|
|||
responseJson.push(latestPriceInfo.priceFeed.toJson());
|
||||
}
|
||||
|
||||
if (notFoundIds.length > 0) {
|
||||
res.status(StatusCodes.BAD_REQUEST).send(`Price Feeds with ids ${notFoundIds.join(', ')} not found`);
|
||||
return;
|
||||
}
|
||||
|
||||
res.json(responseJson);
|
||||
});
|
||||
endpoints.push("latest_price_feed?id[]=<price_feed_id>&id[]=<price_feed_id_2>&..");
|
||||
|
|
Loading…
Reference in New Issue