Skip to content

Instantly share code, notes, and snippets.

@rjchow

rjchow/index.js

Created Jan 27, 2021
Embed
What would you like to do?
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