mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
config loading bug fix
This commit is contained in:
parent
da4646ac69
commit
f48186b1cc
@ -14,4 +14,5 @@ Config.Server = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ConfigLoader.init(Config, path.join(__dirname, './../../config.json'), [["PORT", "Server-port"]]);
|
ConfigLoader.init(Config, path.join(__dirname, './../../config.json'), [["PORT", "Server-port"]]);
|
||||||
|
|
||||||
|
|
@ -25,6 +25,7 @@ export class ConfigLoader {
|
|||||||
let argv = optimist.argv;
|
let argv = optimist.argv;
|
||||||
delete(argv._);
|
delete(argv._);
|
||||||
delete(argv.$0);
|
delete(argv.$0);
|
||||||
|
console.log(argv);
|
||||||
this.processHierarchyVar(configObject, argv);
|
this.processHierarchyVar(configObject, argv);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -35,13 +36,23 @@ export class ConfigLoader {
|
|||||||
let keyArray = key.split("-");
|
let keyArray = key.split("-");
|
||||||
let value = vars[key];
|
let value = vars[key];
|
||||||
|
|
||||||
|
//recursive settings
|
||||||
let setObject = (object, keyArray, value) => {
|
let setObject = (object, keyArray, value) => {
|
||||||
let key = keyArray.shift();
|
let key = keyArray.shift();
|
||||||
object[key] = {};
|
object[key] = {};
|
||||||
|
|
||||||
if (keyArray.length == 0) {
|
if (keyArray.length == 0) {
|
||||||
|
//convert to boolean
|
||||||
|
if (value.toLowerCase && value.toLowerCase() === "false") {
|
||||||
|
value = false;
|
||||||
|
}
|
||||||
|
if (value.toLowerCase && value.toLowerCase() === "true") {
|
||||||
|
value = true;
|
||||||
|
}
|
||||||
object[key] = value;
|
object[key] = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return setObject(object[key], keyArray, value);
|
return setObject(object[key], keyArray, value);
|
||||||
};
|
};
|
||||||
setObject(config, keyArray, value);
|
setObject(config, keyArray, value);
|
||||||
|
@ -23,7 +23,6 @@ export class UserManager implements IUserManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
console.log("ctor");
|
|
||||||
this.db = flatfile.sync(path.join(ProjectPath.Root, 'users.db'));
|
this.db = flatfile.sync(path.join(ProjectPath.Root, 'users.db'));
|
||||||
|
|
||||||
if (!this.db.has("idCounter")) {
|
if (!this.db.has("idCounter")) {
|
||||||
@ -33,6 +32,7 @@ export class UserManager implements IUserManager {
|
|||||||
|
|
||||||
if (!this.db.has("users")) {
|
if (!this.db.has("users")) {
|
||||||
this.db.put("users", []);
|
this.db.put("users", []);
|
||||||
|
//TODO: remove defaults
|
||||||
this.createUser(new User("developer", "developer", UserRoles.Developer));
|
this.createUser(new User("developer", "developer", UserRoles.Developer));
|
||||||
this.createUser(new User("admin", "admin", UserRoles.Admin));
|
this.createUser(new User("admin", "admin", UserRoles.Admin));
|
||||||
this.createUser(new User("user", "user", UserRoles.User));
|
this.createUser(new User("user", "user", UserRoles.User));
|
||||||
|
Loading…
Reference in New Issue
Block a user