diff --git a/backend/api/node/nodeController.js b/backend/api/account/accountController.js similarity index 69% rename from backend/api/node/nodeController.js rename to backend/api/account/accountController.js index 7657c26..7be5c4d 100644 --- a/backend/api/node/nodeController.js +++ b/backend/api/account/accountController.js @@ -1,11 +1,11 @@ const debug = require('../../utils/debug'); -const nodeService = require('./nodeService'); +const accountService = require('./accountService'); -const getNodeAllowance = async (req, res) => { +const getAccountBalance = async (req, res) => { try { const username = req._parsedUrl.query.split('=')[1]; username, passphrase, alias, start - const response = await nodeService.getNodeAllowance(username); + const response = await accountService.getAccountBalance(username); debug.info(`Invoice Creation Response: ${JSON.stringify(response)}`); @@ -17,4 +17,4 @@ const getNodeAllowance = async (req, res) => { } }; -module.exports = { getNodeAllowance }; +module.exports = { getAccountBalance }; diff --git a/backend/api/node/nodeService.js b/backend/api/account/accountService.js similarity index 78% rename from backend/api/node/nodeService.js rename to backend/api/account/accountService.js index 2a0cf8e..1bb41d3 100644 --- a/backend/api/node/nodeService.js +++ b/backend/api/account/accountService.js @@ -1,7 +1,7 @@ const debug = require('../../utils/debug'); const senseiAdmin = require('../../sensei/admin'); -const getNodeAllowance = async (username) => { +const getAccountBalance = async (username) => { try { // get allowance from firestore return { success: true, message: charge }; @@ -11,4 +11,4 @@ const getNodeAllowance = async (username) => { } }; -module.exports = { getNodeAllowance }; +module.exports = { getAccountBalance }; diff --git a/backend/api/account/index.js b/backend/api/account/index.js new file mode 100644 index 0000000..9b3d7e7 --- /dev/null +++ b/backend/api/account/index.js @@ -0,0 +1,8 @@ +const express = require('express'); +const router = express(); + +const { getAccountBalance } = require('./accountController'); + +router.get('/allowance', getAccountBalance); + +module.exports = router; diff --git a/backend/api/admin/adminController.js b/backend/api/admin/adminController.js index 513162d..6518af2 100644 --- a/backend/api/admin/adminController.js +++ b/backend/api/admin/adminController.js @@ -1,10 +1,10 @@ const debug = require('../../utils/debug'); -const spotService = require('./adminService'); +const adminService = require('./adminService'); const getParkingSpotDetails = async (req, res) => { try { const uuid = req._parsedUrl.query.split('=')[1]; - const response = await spotService.getParkingSpotDetails(uuid); + const response = await adminService.getParkingSpotDetails(uuid); debug.info(`Spot Details Response: ${JSON.stringify(response)}`); @@ -23,7 +23,7 @@ const reserveParkingSpot = async (req, res) => { const licensePlate = req.body.licensePlate; const duration = req.body.duration; - const response = await spotService.reserveParkingSpot( + const response = await adminService.reserveParkingSpot( uuid, licensePlate, duration @@ -42,7 +42,7 @@ const reserveParkingSpot = async (req, res) => { const shouldBeEmpty = async (req, res) => { try { - const response = await spotService.shouldBeEmpty(); + const response = await adminService.shouldBeEmpty(); debug.info(`Spot Details Response: ${JSON.stringify(response)}`); diff --git a/backend/api/admin/adminService.js b/backend/api/admin/adminService.js index 6e5c1f9..e145e90 100644 --- a/backend/api/admin/adminService.js +++ b/backend/api/admin/adminService.js @@ -1,6 +1,10 @@ const debug = require('../../utils/debug'); + +// replace spots with accounts const spots = require('../../db/collection'); + +// replace all functions const getParkingSpotDetails = async (uuid) => { try { return { success: true, message: (await spots.doc(uuid).get()).data() }; diff --git a/backend/api/node/index.js b/backend/api/node/index.js deleted file mode 100644 index e8048f9..0000000 --- a/backend/api/node/index.js +++ /dev/null @@ -1,9 +0,0 @@ -const express = require('express'); -const router = express(); - -const { getNodeAllowance } = require('./nodeController'); - - -router.get('/allowance', getNodeAllowance); - -module.exports = router;