Skip to content

Commit

Permalink
Build proxy
Browse files Browse the repository at this point in the history
Run a proxy over Folding@home web client and capture response data
on each work progress update request.
  • Loading branch information
dnhn committed Apr 14, 2020
0 parents commit 0180407
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
package-lock.json
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
18 changes: 18 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const app = require('express')();
const proxy = require('express-http-proxy');

const HOST = 'http://127.0.0.1';
const PORT = 4444;
const FAH = `${HOST}:7396`;

app.use(proxy(FAH, {
userResDecorator: (_, proxyData, userReq) => {
if (userReq.path === '/api/updates' && proxyData) {
console.log(JSON.parse(proxyData.toString('utf-8'))[0]);
}
return new Promise(resolve => resolve(proxyData));
}
}));
app.listen(PORT, () => console.log(`Proxy is running at ${HOST}:${PORT}\n`));

module.exports = app;
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "fah-web-proxy",
"version": "0.1.0",
"private": true,
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"express": "4.16.1",
"express-http-proxy": "1.6.0"
}
}

0 comments on commit 0180407

Please sign in to comment.