mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 21:36:05 +01:00
server-ts: Port sync_options
This commit is contained in:
30
src/services/sync_options.ts
Normal file
30
src/services/sync_options.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
|
||||
import optionService = require('./options');
|
||||
import config = require('./config');
|
||||
|
||||
/*
|
||||
* Primary configuration for sync is in the options (document), but we allow to override
|
||||
* these settings in config file. The reason for that is to avoid a mistake of loading a live/production
|
||||
* document with live sync settings in a dev/debug environment. Changes would then successfully propagate
|
||||
* to live sync server.
|
||||
*/
|
||||
|
||||
function get(name: string) {
|
||||
return (config['Sync'] && config['Sync'][name]) || optionService.getOption(name);
|
||||
}
|
||||
|
||||
export = {
|
||||
// env variable is the easiest way to guarantee we won't overwrite prod data during development
|
||||
// after copying prod document/data directory
|
||||
getSyncServerHost: () => process.env.TRILIUM_SYNC_SERVER_HOST || get('syncServerHost'),
|
||||
isSyncSetup: () => {
|
||||
const syncServerHost = get('syncServerHost');
|
||||
|
||||
// special value "disabled" is here to support a use case where the document is configured with sync server,
|
||||
// and we need to override it with config from config.ini
|
||||
return !!syncServerHost && syncServerHost !== 'disabled';
|
||||
},
|
||||
getSyncTimeout: () => parseInt(get('syncServerTimeout')) || 120000,
|
||||
getSyncProxy: () => get('syncProxy')
|
||||
};
|
||||
Reference in New Issue
Block a user