ProxmoxAAS-API/db.js
Arthur Lu f21d3cffea separate user data endpoints
Signed-off-by: Arthur Lu <learthurgo@gmail.com>
2023-05-12 20:51:07 +00:00

28 lines
472 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];
}