add bucket check endpoint
This commit is contained in:
parent
0f9e34f426
commit
c6c3edff8b
|
@ -5,7 +5,7 @@ const Account = require('./account.js');
|
||||||
const utils = require('./utils.js');
|
const utils = require('./utils.js');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const argv = parseArgs(process.argv.slice(2), {string: ["sender"], default: {"endpoint": "ws://127.0.0.1:8546"}});
|
const argv = parseArgs(process.argv.slice(2), {string: ["sender", "bucket"], default: {"endpoint": "ws://127.0.0.1:8546"}});
|
||||||
const web3 = new Web3(argv["endpoint"]);
|
const web3 = new Web3(argv["endpoint"]);
|
||||||
const account = new Account(web3);
|
const account = new Account(web3);
|
||||||
|
|
||||||
|
@ -72,6 +72,14 @@ async function redeemRequest(req, res) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bucketRequest(req, res) {
|
||||||
|
if (validateBucket(req.params.address)) {
|
||||||
|
res.status(200).json({"allowed": true});
|
||||||
|
} else {
|
||||||
|
res.status(404).json({"allowed": false});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function loadBucketList(path) {
|
function loadBucketList(path) {
|
||||||
let file = fs.readFileSync(path, 'utf8');
|
let file = fs.readFileSync(path, 'utf8');
|
||||||
allowedBuckets = file.split("\n").map((line) => line.toLowerCase().trim());
|
allowedBuckets = file.split("\n").map((line) => line.toLowerCase().trim());
|
||||||
|
@ -109,6 +117,7 @@ async function run() {
|
||||||
|
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.post('/redeem', redeemRequest);
|
app.post('/redeem', redeemRequest);
|
||||||
|
app.get('/bucket/:address', bucketRequest);
|
||||||
app.listen(port, () => console.log(`Relayer listening at http://localhost:${port}`));
|
app.listen(port, () => console.log(`Relayer listening at http://localhost:${port}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue