-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelay.js
More file actions
28 lines (24 loc) · 740 Bytes
/
relay.js
File metadata and controls
28 lines (24 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const request = require('superagent');
const express = require('express');
const app = express();
const port = process.env.PORT || 8001;
// need to change the localhost to the url
const relayHost = process.env.RELAY_HOST || 'localhost';
const relayPort = process.env.RELAY_PORT || 8000;
const relayPath = process.env.RELAY_PATH || '/businesses';
const relayURL =
`http://${relayHost}:${relayPort}${relayPath}`;
app.get('/', function (req, res) {
request
.get(relayURL)
.end(function (err, relayRes) {
if (err) {
res.status(500).send(err);
} else {
res.status(200).send(relayRes.body);
}
});
});
app.listen(port, function() {
console.log("== Relaying", relayURL, "on port", port);
});