Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
Add responseCode based on the diff
Browse files Browse the repository at this point in the history
  • Loading branch information
khorolets committed Sep 13, 2021
1 parent 1eac779 commit 1cc1461
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion frontend/src/pages/api/status-indexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ export default async function (req, res) {
rpc_latest_block_height: rpcFinalBlock.header.height,
indexer_latest_block_height: indexerFinalBlock[0].height,
};
res.status(200).send(statusResponse);

let responseCode = 503;
if (
Math.abs(
status.rpc_latest_block_height -
statusResponse.indexer_latest_block_height
) <= 30
) {
responseCode = 200;
}

res.status(responseCode).send(statusResponse);
} catch (error) {
console.error(error);
res.status(502).send(error);
Expand Down

0 comments on commit 1cc1461

Please sign in to comment.