ProxmoxAAS-API/db.js

28 lines
472 B
JavaScript
Raw Normal View History

import { readFileSync, writeFileSync } from "fs";
2023-02-27 01:09:49 +00:00
let template = "localdb.json.template"
let filename = "localdb.json";
2023-02-27 01:09:49 +00:00
let db = JSON.parse(readFileSync(template));
try {
load();
}
catch {
save();
2023-02-27 01:28:01 +00:00
}
2023-04-19 02:42:35 +00:00
function load () {
db = JSON.parse(readFileSync(filename));
2023-02-27 01:28:01 +00:00
}
2023-04-19 02:42:35 +00:00
function save () {
writeFileSync(filename, JSON.stringify(db));
2023-04-19 02:42:35 +00:00
}
export function getResourceConfig () {
return db.resources;
2023-02-27 01:28:01 +00:00
}
export function getUserConfig (username) {
2023-04-19 02:42:35 +00:00
return db.users[username];
}