diff --git a/backend/api/node/index.js b/backend/api/node/index.js index 66b09d4..e8048f9 100644 --- a/backend/api/node/index.js +++ b/backend/api/node/index.js @@ -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; diff --git a/backend/api/node/nodeController.js b/backend/api/node/nodeController.js index 1c7bd1c..7657c26 100644 --- a/backend/api/node/nodeController.js +++ b/backend/api/node/nodeController.js @@ -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)}`); @@ -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 }; diff --git a/backend/api/node/nodeService.js b/backend/api/node/nodeService.js index e05b952..2a0cf8e 100644 --- a/backend/api/node/nodeService.js +++ b/backend/api/node/nodeService.js @@ -1,13 +1,9 @@ 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); @@ -15,4 +11,4 @@ const getAllowance = async (amount, memo) => { } }; -module.exports = { getAllowance }; +module.exports = { getNodeAllowance }; diff --git a/backend/db/collection.js b/backend/db/collection.js index d852dc3..2752fde 100644 --- a/backend/db/collection.js +++ b/backend/db/collection.js @@ -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}`);