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