Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import jq from "node-jq";

const app = express();
app.use(cors());
const url = process.env["URL"] || "http://127.0.0.1";
const port = process.env["PORT"] || 3000;
const rpcPort = process.env["RPC_PORT"] || 51473;
const testnetRpcPort = process.env["TESTNET_RPC_PORT"];
Expand Down Expand Up @@ -41,7 +42,7 @@ const encodeBase64 = (data) => {
async function makeRpc(isTestnet, name, ...params) {
try {
const output = await fetch(
`http://127.0.0.1:${isTestnet ? testnetRpcPort : rpcPort}/`,
`${url}:${isTestnet ? testnetRpcPort : rpcPort}/`,
{
method: "POST",
headers: {
Expand All @@ -55,7 +56,7 @@ async function makeRpc(isTestnet, name, ...params) {
method: name,
params,
}),
}
},
);

const obj = await output.json();
Expand Down Expand Up @@ -94,15 +95,15 @@ async function handleRequest(isTestnet, req, res) {
const { status, response } = await makeRpc(
isTestnet,
req.params["rpc"],
...params
...params,
);
try {
res
.status(status)
.send(
filter
? await jq.run(filter, response, { input: "string" })
: response
: response,
);
} catch (e) {
const badRequest = 400;
Expand Down