1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00
pigallery2/common/config/private/PrivateConfigClass.ts

64 lines
1.5 KiB
TypeScript
Raw Normal View History

2017-06-04 15:25:08 +02:00
import {PublicConfigClass} from "../public/ConfigClass";
2017-07-08 12:43:42 +02:00
import {DatabaseType, IPrivateConfig, ServerConfig, ThumbnailProcessingLib} from "./IPrivateConfig";
import * as path from "path";
import {ConfigLoader} from "typeconfig";
2017-06-04 15:25:08 +02:00
/**
* This configuration will be only at backend
*/
2017-07-08 12:43:42 +02:00
export class PrivateConfigClass extends PublicConfigClass implements IPrivateConfig {
2017-06-04 15:25:08 +02:00
public Server: ServerConfig = {
port: 80,
imagesFolder: "demo/images",
thumbnail: {
folder: "demo/TEMP",
processingLibrary: ThumbnailProcessingLib.sharp,
qualityPriority: true
},
database: {
type: DatabaseType.mysql,
mysql: {
2017-07-13 23:39:09 +02:00
host: "",
username: "",
password: "",
database: ""
2017-06-04 15:25:08 +02:00
}
},
2017-07-03 19:17:49 +02:00
sharing: {
updateTimeout: 1000 * 60 * 5
},
enableThreading: true
};
2017-07-08 12:43:42 +02:00
private ConfigLoader: any;
2017-06-04 15:25:08 +02:00
public setDatabaseType(type: DatabaseType) {
this.Server.database.type = type;
if (type === DatabaseType.memory) {
2017-07-13 23:39:09 +02:00
this.Client.Search.enabled = false;
this.Client.Search.instantSearchEnabled = false;
this.Client.Search.autocompleteEnabled = false;
2017-07-13 23:39:09 +02:00
this.Client.Sharing.enabled = false;
2017-06-04 15:25:08 +02:00
}
}
2017-06-04 15:25:08 +02:00
2017-07-08 12:43:42 +02:00
public load() {
ConfigLoader.loadBackendConfig(this,
path.join(__dirname, './../../../config.json'),
[["PORT", "Server-port"]]);
}
public save() {
ConfigLoader.saveConfigFile(path.join(__dirname, './../../../config.json'), this);
}
2017-07-12 18:31:19 +02:00
public original(): PrivateConfigClass {
let cfg = new PrivateConfigClass();
cfg.load();
return cfg;
}
2017-06-04 15:25:08 +02:00
}