2018-05-12 12:19:51 -04:00
|
|
|
import {PublicConfigClass} from '../public/ConfigClass';
|
|
|
|
import {DatabaseType, IPrivateConfig, ReIndexingSensitivity, 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
|
|
|
|
2017-06-11 23:33:47 +02:00
|
|
|
public Server: ServerConfig = {
|
|
|
|
port: 80,
|
2018-05-12 12:19:51 -04:00
|
|
|
imagesFolder: 'demo/images',
|
2017-06-11 23:33:47 +02:00
|
|
|
thumbnail: {
|
2018-05-12 12:19:51 -04:00
|
|
|
folder: 'demo/TEMP',
|
2017-06-11 23:33:47 +02:00
|
|
|
processingLibrary: ThumbnailProcessingLib.sharp,
|
|
|
|
qualityPriority: true
|
|
|
|
},
|
2017-07-16 10:59:28 +02:00
|
|
|
sessionTimeout: 1000 * 60 * 60 * 24 * 7,
|
2017-06-11 23:33:47 +02:00
|
|
|
database: {
|
2017-07-20 23:37:10 +02:00
|
|
|
type: DatabaseType.sqlite,
|
2017-06-11 23:33:47 +02:00
|
|
|
mysql: {
|
2018-05-12 12:19:51 -04:00
|
|
|
host: '',
|
|
|
|
username: '',
|
|
|
|
password: '',
|
|
|
|
database: ''
|
2017-06-04 15:25:08 +02:00
|
|
|
|
2017-07-20 23:37:10 +02:00
|
|
|
},
|
|
|
|
sqlite: {
|
2018-05-12 12:19:51 -04:00
|
|
|
storage: 'sqlite.db'
|
2017-06-11 23:33:47 +02:00
|
|
|
}
|
|
|
|
},
|
2017-07-03 19:17:49 +02:00
|
|
|
sharing: {
|
|
|
|
updateTimeout: 1000 * 60 * 5
|
|
|
|
},
|
2018-11-02 16:24:37 +01:00
|
|
|
threading: {
|
|
|
|
enable: true,
|
|
|
|
thumbnailThreads: 0
|
|
|
|
},
|
2017-07-27 23:10:16 +02:00
|
|
|
indexing: {
|
|
|
|
folderPreviewSize: 2,
|
|
|
|
cachedFolderTimeout: 1000 * 60 * 60,
|
2017-07-28 00:04:19 +02:00
|
|
|
reIndexingSensitivity: ReIndexingSensitivity.medium
|
2018-11-02 16:24:37 +01:00
|
|
|
}
|
2017-06-11 23:33:47 +02:00
|
|
|
};
|
2017-07-08 12:43:42 +02:00
|
|
|
private ConfigLoader: any;
|
2017-06-04 15:25:08 +02:00
|
|
|
|
2017-06-11 23:33:47 +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.Sharing.enabled = false;
|
2017-06-04 15:25:08 +02:00
|
|
|
}
|
2017-06-11 23:33:47 +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'),
|
2018-05-12 12:19:51 -04:00
|
|
|
[['PORT', 'Server-port']]);
|
2017-07-08 12:43:42 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public save() {
|
2018-12-02 12:22:05 +01:00
|
|
|
try {
|
|
|
|
ConfigLoader.saveConfigFile(path.join(__dirname, './../../../config.json'), this);
|
|
|
|
} catch (e) {
|
|
|
|
throw new Error('Error during saving config: ' + e.toString());
|
|
|
|
}
|
2017-07-08 12:43:42 +02:00
|
|
|
}
|
2017-07-12 18:31:19 +02:00
|
|
|
|
|
|
|
public original(): PrivateConfigClass {
|
2018-05-12 12:19:51 -04:00
|
|
|
const cfg = new PrivateConfigClass();
|
2017-07-12 18:31:19 +02:00
|
|
|
cfg.load();
|
|
|
|
return cfg;
|
|
|
|
}
|
2017-06-04 15:25:08 +02:00
|
|
|
}
|
|
|
|
|