| 113 | const getStartup = (req, res) => res.send(startUp); |
| 114 | |
| 115 | const getConfig = (req, res) => { |
| 116 | const obj = config.hideConfigSecrets ? configObj.redactedConf : configObj.fullConf; |
| 117 | // Functions can't survive JSON.stringify, so we wrap them in a |
| 118 | // tagged object { __mmFunction: "<source>" }. The client-side |
| 119 | // JSON reviver in main.js recognises this tag and reconstructs |
| 120 | // the live function from the source string. |
| 121 | const jsonString = JSON.stringify(obj, (key, value) => { |
| 122 | if (typeof value === "function") { |
| 123 | return { __mmFunction: value.toString() }; |
| 124 | } |
| 125 | return value; |
| 126 | }); |
| 127 | res.set("Content-Type", "application/json"); |
| 128 | res.send(jsonString); |
| 129 | }; |
| 130 | |
| 131 | app.get("/config", (req, res) => getConfig(req, res)); |
| 132 | |