fix issue with localdb,
rename db.js to localdb.js add option to dynamically load db backend
This commit is contained in:
parent
3146ae76a6
commit
cb1e3a776e
@ -8,11 +8,11 @@ class LocalDB {
|
||||
try {
|
||||
this.#path = path;
|
||||
this.#load();
|
||||
this.pveAPI = this.getConfig().application.pveAPI;
|
||||
this.pveAPIToken = this.getConfig().application.pveAPIToken;
|
||||
this.listenPort = this.getConfig().application.listenPort;
|
||||
this.hostname = this.getConfig().application.hostname;
|
||||
this.domain = this.getConfig().application.domain;
|
||||
this.pveAPI = this.getGlobal().application.pveAPI;
|
||||
this.pveAPIToken = this.getGlobal().application.pveAPIToken;
|
||||
this.listenPort = this.getGlobal().application.listenPort;
|
||||
this.hostname = this.getGlobal().application.hostname;
|
||||
this.domain = this.getGlobal().application.domain;
|
||||
}
|
||||
catch {
|
||||
console.log(`Error: ${path} was not found. Please follow the directions in the README to initialize localdb.json.`);
|
@ -7,20 +7,21 @@ import morgan from "morgan";
|
||||
import _package from "./package.js";
|
||||
import * as pve from "./pve.js";
|
||||
import * as utils from "./utils.js";
|
||||
import LocalDB from "./db.js";
|
||||
|
||||
import parseArgs from "minimist";
|
||||
global.argv = parseArgs(process.argv.slice(2), {
|
||||
default: {
|
||||
package: "package.json",
|
||||
localdb: "config/localdb.json"
|
||||
db: "./localdb.js", // relative to main.js
|
||||
dbconfig: "config/localdb.json"
|
||||
}
|
||||
});
|
||||
|
||||
global.api = _package(global.argv.package);
|
||||
global.pve = pve;
|
||||
global.utils = utils;
|
||||
global.db = new LocalDB(global.argv.localdb);
|
||||
const db = (await import(global.argv.db)).default;
|
||||
global.db = new db(global.argv.dbconfig);
|
||||
|
||||
const app = express();
|
||||
global.app = app;
|
||||
|
Loading…
Reference in New Issue
Block a user