From 2cd23324e5478947ad97ca6dbbe1d7ed49726d85 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Wed, 17 May 2023 21:38:11 +0000 Subject: [PATCH] fix formatting --- db.js | 8 ++++---- package.json | 2 +- utils.js | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/db.js b/db.js index 7fe4ccd..4edee35 100644 --- a/db.js +++ b/db.js @@ -11,18 +11,18 @@ catch { save(); } -function load () { +function load() { db = JSON.parse(readFileSync(filename)); } -function save () { +function save() { writeFileSync(filename, JSON.stringify(db)); } -export function getResourceConfig () { +export function getResourceConfig() { return db.resources; } -export function getUserConfig (username) { +export function getUserConfig(username) { return db.users[username]; } \ No newline at end of file diff --git a/package.json b/package.json index 96a6914..41f91b2 100644 --- a/package.json +++ b/package.json @@ -12,4 +12,4 @@ "express": "^4.18.2", "morgan": "^1.10.0" } -} +} \ No newline at end of file diff --git a/utils.js b/utils.js index c1a9176..55df6d2 100644 --- a/utils.js +++ b/utils.js @@ -1,7 +1,7 @@ import { getUsedResources } from "./pve.js"; import { getUserConfig, getResourceConfig } from "./db.js"; -export async function getAllocatedResources (req, username) { +export async function getAllocatedResources(req, username) { let dbResources = getResourceConfig(); let used = await getUsedResources(req, dbResources); let max = getUserConfig(username).resources.max; @@ -9,10 +9,10 @@ export async function getAllocatedResources (req, username) { Object.keys(max).forEach((k) => { avail[k] = max[k] - used[k]; }); - return {used: used, max: max, avail: avail, units: dbResources}; + return { used: used, max: max, avail: avail, units: dbResources }; } -export async function approveResources (req, username, request) { +export async function approveResources(req, username, request) { let avail = (await getAllocatedResources(req, username)).avail;