Skip to content

Instantly share code, notes, and snippets.

@rjchow
Created January 27, 2021 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjchow/5b95f9ce9ad15c9e1f71640dafe72c83 to your computer and use it in GitHub Desktop.
Save rjchow/5b95f9ce9ad15c9e1f71640dafe72c83 to your computer and use it in GitHub Desktop.
Simple Quorum Proxy
const express = require('express');
const morgan = require("morgan");
import fetch from 'node-fetch';
import { json } from 'body-parser';
require('dotenv').config()
const app = express();
// Configuration
const PORT = 8545;
const HOST = "localhost";
app.use(morgan('dev'));
app.use(json())
app.post('/proxy', async (req, res) => {
const rr = await fetch(process.env.QUORUM_NODE_URL,
{ method: 'POST',
body: JSON.stringify(req.body),
headers: {
'Content-Type': 'application/json',
'authorization': 'Basic ' + Buffer.from(process.env.QUORUM_USERNAME + ":" + process.env.QUORUM_PASSWORD).toString('base64') }})
res.send(await rr.json())
})
// Start Proxy
app.listen(PORT, HOST, () => {
console.log(`Starting Proxy at ${HOST}:${PORT}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment