Notes/src/services/sync_options.js

29 lines
1.0 KiB
JavaScript
Raw Normal View History

"use strict";
const optionService = require('./options');
const 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.
*/
2020-06-20 12:31:38 +02:00
function get(name) {
return (config['Sync'] && config['Sync'][name]) || optionService.getOption(name);
}
module.exports = {
2020-06-20 12:31:38 +02:00
getSyncServerHost: () => get('syncServerHost'),
isSyncSetup: () => {
const syncServerHost = get('syncServerHost');
2018-12-22 09:54:09 +01:00
// special value "disabled" is here to support use case where document is configured with sync server
// and we need to override it with config from config.ini
return !!syncServerHost && syncServerHost !== 'disabled';
},
2021-02-10 22:56:23 +01:00
getSyncTimeout: () => parseInt(get('syncServerTimeout')) || 120000,
2020-06-20 12:31:38 +02:00
getSyncProxy: () => get('syncProxy')
};