This repository was archived by the owner on Jun 24, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathsync_options.ts
More file actions
34 lines (29 loc) · 1.32 KB
/
sync_options.ts
File metadata and controls
34 lines (29 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"use strict";
import optionService from "./options.js";
import config from "./config.js";
import { normalizeUrl } from "./utils.js";
/*
* 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: keyof typeof config.Sync) {
return (config["Sync"] && config["Sync"][name]) || optionService.getOption(name);
}
export default {
// env variable is the easiest way to guarantee we won't overwrite prod data during development
// after copying prod document/data directory
getSyncServerHost: () => {
const host = get("syncServerHost");
return host ? normalizeUrl(host) : host;
},
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")
};