fix formatting
This commit is contained in:
parent
414c08fbf5
commit
e83cf890e7
8
db.js
8
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];
|
||||
}
|
@ -12,4 +12,4 @@
|
||||
"express": "^4.18.2",
|
||||
"morgan": "^1.10.0"
|
||||
}
|
||||
}
|
||||
}
|
6
utils.js
6
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user