()
| 7 | let uri; |
| 8 | |
| 9 | async function getSetup() { |
| 10 | if (NODE && uri) { |
| 11 | return { NODE, uri }; |
| 12 | } |
| 13 | |
| 14 | NODE = true; |
| 15 | if (typeof window !== 'undefined') { |
| 16 | NODE = false; |
| 17 | uri = `//${window.location.host}`; |
| 18 | } else { |
| 19 | try { |
| 20 | const port = await getPort(); |
| 21 | |
| 22 | // check that another call to the function hasn't set the uri already |
| 23 | if (!uri) { |
| 24 | process.env.ZUUL_PORT = port; |
| 25 | uri = `http://localhost:${process.env.ZUUL_PORT}`; |
| 26 | require('./server'); |
| 27 | } |
| 28 | } catch (err) { |
| 29 | console.error(err); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | return { NODE, uri }; |
| 34 | } |
| 35 | |
| 36 | module.exports = getSetup; |
no outgoing calls
no test coverage detected