c7c1191587
disk paths now under instance Signed-off-by: Arthur Lu <learthurgo@gmail.com>
30 lines
488 B
JavaScript
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}; |