-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
bnonni
committed
May 7, 2022
1 parent
e69de52
commit 25ea534
Showing
9 changed files
with
132 additions
and
35 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,21 @@ | ||
const debug = require('../../utils/debug'); | ||
const accounts = require('../../db/collection'); | ||
const senseiAdmin = require('../../sensei/admin'); | ||
const senseiNodes = require('../../sensei/nodes'); | ||
|
||
module.exports = { }; | ||
const getAllBalances = async (req, res) => { | ||
try { | ||
const response = await senseiAdmin.listNodes(); | ||
let nodes = []; | ||
for (let node of response.nodes) { | ||
node.balance = await senseiNodes.getBalance(node.username); | ||
nodes.push(node);x | ||
} | ||
return { success: true, message: nodes }; | ||
} catch (error) { | ||
debug.error(error.stack); | ||
throw new Error(error); | ||
} | ||
}; | ||
|
||
module.exports = { getAllBalances }; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,9 @@ | |
"repository": "[email protected]:atlantabitdevs/familybtc.git", | ||
"author": "[email protected]", | ||
"license": "MIT", | ||
"private": false, | ||
"scripts": { | ||
"start": "NODE_ENV=prod node server.js", | ||
"dev": "NODE_ENV=local nodemon server.js" | ||
"start": "PORT=8080 node server.js", | ||
"dev": "PORT=8081 nodemon server.js" | ||
}, | ||
"dependencies": { | ||
"cors": "^2.8.5", | ||
|
@@ -20,6 +19,7 @@ | |
"http-errors": "^2.0.0", | ||
"mailgun-js": "^0.22.0", | ||
"morgan": "^1.10.0", | ||
"node-fetch": "2.6.6", | ||
"nodemon": "^2.0.15", | ||
"opennode": "^1.3.0", | ||
"uuid": "^8.3.2", | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const fetch = require('node-fetch'); | ||
const BASE_URL = process.env.BASE_URL; | ||
const MACAROON = process.env.MACAROON; | ||
const TOKEN = process.env.TOKEN; | ||
|
||
const apiCall = async (path, method, json={}) => { | ||
return await fetch(BASE_URL + path, { | ||
method: method, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Cookie': `macaroon=${MACAROON}; token=${TOKEN}` | ||
}, | ||
credentials: 'include', | ||
body: JSON.stringify(json), | ||
}); | ||
}; | ||
|
||
module.exports = { apiCall } |