-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.js
69 lines (61 loc) · 2.1 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
const Conf = require("conf");
const config = new Conf({
projectSuffix: "",
cwd: process.env.HOME + "/.config/roboflow",
projectName: "roboflow"
});
const DEFAULTS = {
//Tip: export NODE_TLS_REJECT_UNAUTHORIZED=0 to bypass certificate validation when using local environment
RF_APP_URL: "https://app.roboflow.com",
RF_API_URL: "https://api.roboflow.com",
RF_OBJECT_DETECTION_URL: "https://detect.roboflow.com",
RF_CLASSIFICATION_URL: "https://classify.roboflow.com",
RF_INSTANCE_SEGMENTATION_URL: "https://outline.roboflow.com",
RF_SEMANTIC_SEGMENTATION_URL: "https://segment.roboflow.com"
};
// env vars take precedence over config values
function getCascadingConfigValue(key, defaultValue) {
if (key.startsWith("RF_") && process.env[key]) {
return process.env[key];
} else if (config.has(key)) {
return config.get(key);
} else {
return DEFAULTS[key];
}
}
module.exports = {
get: function (key) {
return getCascadingConfigValue(key);
},
set(key, value) {
return config.set(key, value);
},
getAll() {
return {
...config.store,
RF_WORKSPACE: getCascadingConfigValue("RF_WORKSPACE"),
RF_APP_URL: getCascadingConfigValue("RF_APP_URL"),
RF_API_URL: getCascadingConfigValue("RF_API_URL"),
RF_OBJECT_DETECTION_URL: getCascadingConfigValue(
"RF_OBJECT_DETECTION_URL",
"https://detect.roboflow.com"
),
RF_CLASSIFICATION_URL: getCascadingConfigValue(
"RF_CLASSIFICATION_URL",
"https://classify.roboflow.com"
),
RF_INSTANCE_SEGMENTATION_URL: getCascadingConfigValue(
"RF_INSTANCE_SEGMENTATION_URL",
"https://outline.roboflow.com"
),
RF_SEMANTIC_SEGMENTATION_URL: getCascadingConfigValue(
"RF_SEMANTIC_SEGMENTATION_URL",
"https://segment.roboflow.com"
)
};
},
clear() {
return config.clear();
},
configFile: config.path
};