ProxmoxAAS-API/db.js
Arthur Lu c7c1191587 code cleanup,
disk paths now under instance

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
2023-04-24 21:28:58 +00:00

30 lines
488 B
JavaScript

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