From 0043e3e783309cac99e635c2efd933603c52b948 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Fri, 9 Jun 2023 02:05:26 +0000 Subject: [PATCH] fix formatting --- db.js | 8 ++++---- pve.js | 4 ++-- utils.js | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/db.js b/db.js index 20369d3..3c12a46 100644 --- a/db.js +++ b/db.js @@ -4,7 +4,7 @@ class localdb { #template = "localdb.json.template"; #filename = "localdb.json"; #data = null; - constructor () { + constructor() { try { this.load(this.#filename); } @@ -15,14 +15,14 @@ class localdb { } load(path) { this.#data = JSON.parse(readFileSync(path)); - } + } save(path) { writeFileSync(path, JSON.stringify(this.#data)); } - getResourceConfig () { + getResourceConfig() { return this.#data.resources; } - getUserConfig (username) { + getUserConfig(username) { if (this.#data.users[username]) { return this.#data.users[username]; } diff --git a/pve.js b/pve.js index 178ba29..7c3405d 100644 --- a/pve.js +++ b/pve.js @@ -35,7 +35,7 @@ export async function requestPVE(path, method, cookies, body = null, token = nul export async function handleResponse(node, result, res) { const waitFor = delay => new Promise(resolve => setTimeout(resolve, delay)); - if (result.data.data && typeof(result.data.data) === "string" && result.data.data.startsWith("UPID:")) { + if (result.data.data && typeof (result.data.data) === "string" && result.data.data.startsWith("UPID:")) { let upid = result.data.data; while (true) { let taskStatus = await requestPVE(`/nodes/${node}/tasks/${upid}/status`, "GET", null, null, pveAPIToken); @@ -62,7 +62,7 @@ export async function handleResponse(node, result, res) { } else { res.status(result.status).send(result.data); - res.end(); + res.end(); } } diff --git a/utils.js b/utils.js index d8132c0..05b9c1a 100644 --- a/utils.js +++ b/utils.js @@ -27,7 +27,7 @@ export async function checkAuth(cookies, res, vmpath = null) { return auth; } -export async function getUserResources (req, username) { +export async function getUserResources(req, username) { let dbResources = db.getResourceConfig(); let used = await getUsedResources(req, dbResources); let max = db.getUserConfig(username).resources.max; @@ -50,7 +50,7 @@ export async function approveResources(req, username, request) { } else if (avail[key] - request[key] < 0) { // if the avail resources is less than the requested resources, block approved = false; - } + } }); return approved; // if all requested resources pass, allow } \ No newline at end of file