-
Notifications
You must be signed in to change notification settings - Fork 26
/
config.js
82 lines (73 loc) · 2.35 KB
/
config.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
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
81
82
import globalWindow from 'global/window.js'
export const endpoints = {
getMarketData: `${import.meta.env?.VITE_API_ROOT}api/get-market-data`,
postDayResults: `${import.meta.env?.VITE_API_ROOT}api/post-day-results`,
}
// Represents all of the features enabled for the current environment. Features
// are enabled by environment-specific envars that start with
// "VITE_ENABLE_" prefix. The name of the enabled feature is the part of
// the envar name that follows the prefix. So, `VITE_ENABLE_MINING=true`
// in a .env file will enable the "MINING" feature for its corresponding
// environment.
//
// See: https://create-react-app.dev/docs/adding-custom-environment-variables/
//
// In addition to enabling features via envars, end users can manually enable
// them via URL query parameters. This can be done by constructing a query
// parameter that looks like:
//
// ?enable_FOREST=true
/**
* @type {{
* FOREST?: boolean
* }}
*/
export const features = Object.keys(import.meta.env ?? {}).reduce(
(acc, key) => {
const matches = key.match(/VITE_ENABLE_(.*)/)
if (matches) {
acc[matches[1]] = true
}
return acc
},
{}
)
// Use optional chaining here because window.location will not be defined when
// this is running in a Node.js context.
const searchParams = new URLSearchParams(globalWindow.location?.search)
for (const key of searchParams.keys()) {
const matches = key.match(/enable_(.*)/)
if (matches) {
features[matches[1]] = true
}
}
export const rtcConfig = {
iceServers: [
{
urls: 'stun:stun.relay.metered.ca:80',
},
{
urls: 'turn:a.relay.metered.ca:80',
username: import.meta.env?.VITE_TURN_USERNAME,
credential: import.meta.env?.VITE_TURN_CREDENTIAL,
},
{
urls: 'turn:a.relay.metered.ca:80?transport=tcp',
username: import.meta.env?.VITE_TURN_USERNAME,
credential: import.meta.env?.VITE_TURN_CREDENTIAL,
},
{
urls: 'turn:a.relay.metered.ca:443',
username: import.meta.env?.VITE_TURN_USERNAME,
credential: import.meta.env?.VITE_TURN_CREDENTIAL,
},
{
urls: 'turn:a.relay.metered.ca:443?transport=tcp',
username: import.meta.env?.VITE_TURN_USERNAME,
credential: import.meta.env?.VITE_TURN_CREDENTIAL,
},
],
}
export const trackerUrls = import.meta.env?.VITE_TRACKER_URL
? [import.meta.env?.VITE_TRACKER_URL]
: undefined