mirror of
https://github.com/Ride-The-Lightning/RTL.git
synced 2024-11-19 09:50:36 +01:00
02ffe76abf
Progressbar Home update
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
var fs = require('fs');
|
|
var request = require('request');
|
|
var options = require("../connect");
|
|
var config = require('../config');
|
|
|
|
exports.getPeers = (req, res, next) => {
|
|
options.url = config.lnd_server_url + '/peers';
|
|
request.get(options, (error, response, body) => {
|
|
console.log('Peers Received: ' + JSON.stringify(body));
|
|
if(error) {
|
|
res.status(500).json({
|
|
message: "Fetching peers failed!",
|
|
error: error
|
|
});
|
|
} else {
|
|
res.status(200).json(body.peers);
|
|
}
|
|
});
|
|
};
|
|
|
|
exports.postPeer = (req, res, next) => {
|
|
// setTimeout(()=>{res.status(201).json({message: 'Peer Added!'});}, 5000);
|
|
options.url = config.lnd_server_url + '/peers';
|
|
options.form = JSON.stringify({
|
|
addr: { host: req.body.host, pubkey: req.body.pubkey },
|
|
perm: req.body.perm
|
|
});
|
|
console.log('Options: ' + JSON.stringify(options));
|
|
request.post(options, (error, response, body) => {
|
|
console.log('Peer Add Response: ');
|
|
console.log(body);
|
|
if(undefined === body || body.error) {
|
|
res.status(500).json({
|
|
message: "Adding peers failed!",
|
|
error: (undefined === body) ? 'ERROR From Server!' : body.error
|
|
});
|
|
} else {
|
|
res.status(201).json({message: 'Peer Added!'});
|
|
}
|
|
});
|
|
};
|