ProxmoxAAS-API/db.js
2023-04-26 01:18:05 +00:00

28 lines
471 B
JavaScript

import { readFileSync, writeFileSync } from "fs";
let template = "localdb.json.template"
let filename = "localdb.json";
let db = JSON.parse(readFileSync(template));
try {
load();
}
catch {
save();
}
function load () {
db = JSON.parse(readFileSync(filename));
}
function save () {
writeFileSync(filename, JSON.stringify(db));
}
export function getResourceConfig() {
return db.resources;
}
export function getUserConfig (username) {
return db.users[username];
}