From 952e7e590dc817111f297a8bb13abe4266aca2b4 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Thu, 20 Apr 2023 21:39:41 +0000 Subject: [PATCH] minor change to user data to fit additional user data Signed-off-by: Arthur Lu --- main.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.js b/main.js index cfb70ab..eaff0f4 100644 --- a/main.js +++ b/main.js @@ -44,13 +44,14 @@ app.post("/api/proxmox/*", async (req, res) => { // proxy endpoint for POST prox }); async function getUserResources (req, username) { - let used = await getUsedResources(req, getResources()); + let dbResources = getResources(); + let used = await getUsedResources(req, dbResources); let max = getUser(username).resources.max; avail = {}; Object.keys(max).forEach((k) => { avail[k] = max[k] - used[k]; }); - return {used: used, max: max, avail: avail}; + return {used: used, max: max, avail: avail, units: dbResources}; } async function approveResources (request, avail) { @@ -70,8 +71,7 @@ app.get("/api/user/resources", async(req, res) => { // check auth await checkAuth(req.cookies, res); let userResources = await getUserResources(req, req.cookies.username); - userResources.units = getResources(); - res.status(200).send(userResources); + res.status(200).send({resources: userResources}); res.end(); return; });