aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/apiBase.js
diff options
context:
space:
mode:
authorLibravatar Markus Hatvan <markus_hatvan@aon.at>2021-09-14 10:34:04 +0200
committerLibravatar GitHub <noreply@github.com>2021-09-14 10:34:04 +0200
commit979ec02c9a1019152be08705986337e470eabb57 (patch)
tree6021179ad8649112717a499780f475275af487f2 /src/api/apiBase.js
parentrefactor: defensive programming to avoid javascript error for unread badges (diff)
downloadferdium-app-979ec02c9a1019152be08705986337e470eabb57.tar.gz
ferdium-app-979ec02c9a1019152be08705986337e470eabb57.tar.zst
ferdium-app-979ec02c9a1019152be08705986337e470eabb57.zip
chore: codebase improvements (#1930)
Diffstat (limited to 'src/api/apiBase.js')
-rw-r--r--src/api/apiBase.js42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/api/apiBase.js b/src/api/apiBase.js
deleted file mode 100644
index 2fad7eb21..000000000
--- a/src/api/apiBase.js
+++ /dev/null
@@ -1,42 +0,0 @@
1/**
2 * Get API base URL from store
3 */
4import {
5 API_VERSION,
6} from '../environment';
7import {
8 DEV_API_FRANZ_WEBSITE,
9 LIVE_FRANZ_API,
10 LOCAL_HOSTNAME,
11 LOCAL_SERVER,
12 SERVER_NOT_LOADED,
13} from '../config';
14
15// Note: This cannot be used from the internal-server since we are not running within the context of a browser window
16const apiBase = (withVersion = true) => {
17 let url;
18
19 if (!window.ferdi
20 || !window.ferdi.stores.settings
21 || !window.ferdi.stores.settings.all
22 || !window.ferdi.stores.settings.all.app.server) {
23 // Stores have not yet been loaded - return SERVER_NOT_LOADED to force a retry when stores are loaded
24 return SERVER_NOT_LOADED;
25 }
26 if (window.ferdi.stores.settings.all.app.server === LOCAL_SERVER) {
27 // Use URL for local server
28 url = `http://${LOCAL_HOSTNAME}:${window.ferdi.stores.requests.localServerPort}`;
29 } else {
30 // Load URL from store
31 url = window.ferdi.stores.settings.all.app.server;
32 }
33
34 return withVersion ? `${url}/${API_VERSION}` : url;
35};
36
37export default apiBase;
38
39export function termsBase() {
40 // TODO: This needs to handle local vs ferdi vs franz servers
41 return window.ferdi.stores.settings.all.app.server !== LIVE_FRANZ_API ? window.ferdi.stores.settings.all.app.server : DEV_API_FRANZ_WEBSITE;
42}