Created
January 27, 2021 08:32
-
-
Save rjchow/5b95f9ce9ad15c9e1f71640dafe72c83 to your computer and use it in GitHub Desktop.
Simple Quorum Proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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