-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathconstants.js
49 lines (43 loc) · 1.31 KB
/
constants.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
export const CON_ORIGIN = 'https://content.da.live';
export const AEM_ORIGIN = 'https://admin.hlx.page';
export const SUPPORTED_FILES = {
html: 'text/html',
jpeg: 'image/jpeg',
json: 'application/json',
jpg: 'image/jpeg',
png: 'image/png',
gif: 'image/gif',
mp4: 'video/mp4',
pdf: 'application/pdf',
svg: 'image/svg+xml',
};
const DA_ADMIN_ENVS = {
local: 'http://localhost:8787',
stage: 'https://stage-admin.da.live',
prod: 'https://admin.da.live',
};
const DA_COLLAB_ENVS = {
local: 'ws://localhost:4711',
stage: 'wss://stage-collab.da.live',
prod: 'wss://collab.da.live',
};
function getDaEnv(location, key, envs) {
const { href } = location;
const query = new URL(href).searchParams.get(key);
if (query && query === 'reset') {
localStorage.removeItem(key);
} else if (query) {
localStorage.setItem(key, query);
}
return envs[localStorage.getItem(key) || 'prod'];
}
export const getDaAdmin = (() => {
let daAdmin;
return (location) => {
if (!location && daAdmin) return daAdmin;
daAdmin = getDaEnv(location || window.location, 'da-admin', DA_ADMIN_ENVS);
return daAdmin;
};
})();
export const DA_ORIGIN = (() => getDaEnv(window.location, 'da-admin', DA_ADMIN_ENVS))();
export const COLLAB_ORIGIN = (() => getDaEnv(window.location, 'da-collab', DA_COLLAB_ENVS))();