Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | export interface SertoUiConfig { ENVIRONMENT: string; IS_DEV: boolean; FEATURE_FLAGS?: string; SEARCH_API_URL: string; SEARCH_UI_URL: string; SCHEMAS_API_URL: string; SCHEMAS_UI_URL: string; } export const DEV_ENV = "development"; const ENVIRONMENT = process.env.NODE_ENV || DEV_ENV; const domain = window.location.hostname; export let config: SertoUiConfig = { ENVIRONMENT, IS_DEV: ENVIRONMENT === DEV_ENV, FEATURE_FLAGS: process.env.REACT_APP_FEATURE_FLAGS, SEARCH_API_URL: "http://staging.api.search.serto.id", SEARCH_UI_URL: "http://staging.search.serto.id", SCHEMAS_API_URL: "https://staging.api.schemas.serto.id", SCHEMAS_UI_URL: "https://staging.schemas.serto.id", }; Iif (window.location.protocol.includes("https")) { // staging search doesn't have https, so we gotta use beta or else requests will fail config = { ...config, SEARCH_API_URL: "https://beta.api.search.serto.id", SEARCH_UI_URL: "https://beta.search.serto.id", }; } Eif (ENVIRONMENT !== "development") { Iif (domain.includes("serto.id") && domain.includes("staging")) { // config above is right } else Iif (domain.includes("serto.id") && domain.includes("beta")) { config = { ...config, SEARCH_API_URL: "https://beta.api.search.serto.id", SEARCH_UI_URL: "https://beta.search.serto.id", SCHEMAS_API_URL: "https://beta.api.schemas.serto.id", SCHEMAS_UI_URL: "https://beta.schemas.serto.id", }; } else { // prod config = { ...config, SEARCH_API_URL: "https://beta.api.search.serto.id", SEARCH_UI_URL: "https://search.serto.id", SCHEMAS_API_URL: "https://beta.api.schemas.serto.id", SCHEMAS_UI_URL: "https://schemas.serto.id", }; } } export const links = { CONTACT: "https://www.serto.id/about#contact-section", SUITE: "https://www.serto.id/products", SCHEMAS_FEEDBACK: "https://forms.gle/tGLwuYTc1VkKFmhs6", SCHEMAS_PLAYGROUND: `${config.SCHEMAS_UI_URL}/playground`, CREATE_SCHEMA_PATH: "/schemas/", }; export function mergeServerConfig<T extends { [key: string]: any }>(defaultConfig: T): T { const serverConfigString = (window as any).SERVER_CONFIG; let serverConfig: T | undefined; if (serverConfigString && serverConfigString !== "$ENVIRONMENT") { try { serverConfig = JSON.parse(serverConfigString); } catch (e) { console.error("error parsing server config: ", { serverConfigString, defaultConfig, e }); } } const config = { ...defaultConfig, ...serverConfig }; console.log("config loaded", { config, defaultConfig, serverConfig }); return config; } |