Skip to content

Commit

Permalink
Added support for true/false
Browse files Browse the repository at this point in the history
  • Loading branch information
Duddino committed Nov 12, 2022
1 parent 5c4de0e commit 61fb8f7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ async function makeRpc(name, ...params){
const ok = 200;
return { status: ok, response: JSON.stringify(obj.result) };
}
}catch(error){
} catch(error) {
if (error.errno === "ECONNREFUSED") {
return { status: 503, response: JSON.stringify({response: "PIVX node was not responsive."})};
return { status: 503, response: "PIVX node was not responsive."};
}
if (error.name === 'AbortError') {
return "brequbest was aborted'";
Expand All @@ -63,8 +63,9 @@ app.get('/:rpc', async function(req, res) {
if (allowedRpcs.includes(req.params["rpc"])) {

const params = (req.query.params ? req.query.params.split(",") : [])
.map(v=>isNaN(v) ? v : parseInt(v));

.map(v=>isNaN(v) ? v : parseInt(v))
.map(v=>v === "true" ? true : v)
.map(v=>v === "false" ? false : v);
const { status, response } = await makeRpc(req.params["rpc"], ...params);
res.status(status).send(response + "");
} else {
Expand Down

0 comments on commit 61fb8f7

Please sign in to comment.