MCPcopy
hub / github.com/MagicMirrorOrg/MagicMirror / getEnvVars

Function getEnvVars

js/loader.js:25–40  ·  view source on GitHub ↗

* Retrieve object of env variables. * @returns {object} with key: values as assembled in js/server_functions.js

()

Source from the content-addressed store, hash-verified

23 * @returns {object} with key: values as assembled in js/server_functions.js
24 */
25async function getEnvVars () {
26 // In test mode, skip server fetch and use config values directly
27 if (typeof process !== "undefined" && process.env && process.env.mmTestMode === "true") {
28 return getEnvVarsFromConfig();
29 }
30
31 // In production, fetch env vars from server
32 try {
33 const res = await fetch(new URL("env", `${location.origin}${config.basePath}`));
34 return JSON.parse(await res.text());
35 } catch (error) {
36 // Fallback to config values if server fetch fails
37 Log.error("Unable to retrieve env configuration", error);
38 return getEnvVarsFromConfig();
39 }
40}
41
42/**
43 * Loops through all modules and requests start for every module.

Callers 3

getModuleDataFunction · 0.70
loadModulesFunction · 0.70
ServerFunction · 0.70

Calls 2

getEnvVarsFromConfigFunction · 0.85
parseMethod · 0.80

Tested by

no test coverage detected