Skip to content

Commit

Permalink
push
Browse files Browse the repository at this point in the history
  • Loading branch information
bnonni committed May 7, 2022
1 parent 28245db commit 41b6365
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 31 deletions.
4 changes: 2 additions & 2 deletions backend/api/node/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const express = require('express');
const router = express();

const { getAllowance } = require('./node');
const { getNodeAllowance } = require('./nodeController');


router.get('/allowance', getAllowance);
router.get('/allowance', getNodeAllowance);

module.exports = router;
25 changes: 5 additions & 20 deletions backend/api/node/nodeController.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const debug = require('../../utils/debug');
const nodeService = require('./nodeService');

const getAllowance = async (req, res) => {
const getNodeAllowance = async (req, res) => {
try {
const amount = req.body.amount;
const memo = req.body.memo;
const response = await nodeService.getAllowance(amount, memo);
const username = req._parsedUrl.query.split('=')[1];
username, passphrase, alias, start
const response = await nodeService.getNodeAllowance(username);

debug.info(`Invoice Creation Response: ${JSON.stringify(response)}`);

Expand All @@ -17,19 +17,4 @@ const getAllowance = async (req, res) => {
}
};

const checkInvoice = async (req, res) => {
try {
const id = req.body.id
const response = await nodeService.checkInvoice(id);

debug.info(`Invoice Creation Response: ${JSON.stringify(response)}`);

if (!response.success) res.status(500).json(response);
else res.status(200).json(response);
} catch (error) {
debug.error(error.stack);
res.status(500).json({ message: error.message, error: error.stack });
}
};

module.exports = { createInvoice, checkInvoice };
module.exports = { getNodeAllowance };
12 changes: 4 additions & 8 deletions backend/api/node/nodeService.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
const debug = require('../../utils/debug');
const sensei = require('../../sensei/admin');
const senseiAdmin = require('../../sensei/admin');

const getAllowance = async (amount, memo) => {
const getNodeAllowance = async (username) => {
try {
const allowance = await sensei.getAllowance({
amount: amount,
currency: 'USD',
description: JSON.stringify(memo)
});
// get allowance from firestore
return { success: true, message: charge };
} catch (error) {
debug.error(error.stack, error.status, error.message);
throw new Error(error);
}
};

module.exports = { getAllowance };
module.exports = { getNodeAllowance };
2 changes: 1 addition & 1 deletion backend/db/collection.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const debug = require('../utils/debug');
const db = require('./db');
const DB_COLLECTION = 'parkLightning';
const DB_COLLECTION = 'families';

const collection = db.collection(DB_COLLECTION);
debug.info(`Connected to collection ${db.projectId}/${DB_COLLECTION}`);
Expand Down

0 comments on commit 41b6365

Please sign in to comment.