forked from opencoconut/coconutjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.js
43 lines (32 loc) · 801 Bytes
/
client.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
const ENDPOINT = "https://api.coconut.co/v2";
class Client {
constructor(api_key, config={}) {
this.api_key = api_key;
if(config.region) {
this.region = config.region;
}
if(config.endpoint) {
this.endpoint = config.endpoint;
}
if(config.storage) {
this.storage = config.storage;
}
if(config.notification) {
this.notification = config.notification;
}
this.Job = require("./job");
this.Job.cli = this;
this.Metadata = require("./metadata");
this.Metadata.cli = this;
}
getEndpoint() {
if (this.endpoint != undefined) {
return this.endpoint;
}
if(this.region != undefined) {
return "https://api-" + this.region + ".coconut.co/v2"
}
return ENDPOINT;
}
}
module.exports = Client;