exaroton 1.8.3 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exaroton",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "exaroton API client",
|
|
5
5
|
"homepage": "https://exaroton.com",
|
|
6
6
|
"main": "index.js",
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"node": ">=12.0.0"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"form-data": "^3.0.1",
|
|
15
14
|
"got": "^11.8.2",
|
|
16
15
|
"ws": "^7.4.5"
|
|
17
16
|
}
|
package/src/Client.js
CHANGED
|
@@ -106,15 +106,10 @@ class Client {
|
|
|
106
106
|
async request(request) {
|
|
107
107
|
request.client = this;
|
|
108
108
|
const url = this.baseURL + request.getEndpoint();
|
|
109
|
-
const headers = Object.assign({
|
|
110
|
-
"authorization": "Bearer " + this.#apiToken,
|
|
111
|
-
"user-agent": this.#userAgent
|
|
112
|
-
}, request.headers);
|
|
113
109
|
|
|
114
110
|
let gotOptions = {
|
|
115
111
|
method: request.method,
|
|
116
112
|
retry: 0,
|
|
117
|
-
headers: headers,
|
|
118
113
|
responseType: request.responseType
|
|
119
114
|
};
|
|
120
115
|
|
|
@@ -122,6 +117,11 @@ class Client {
|
|
|
122
117
|
gotOptions.body = request.getBody();
|
|
123
118
|
}
|
|
124
119
|
|
|
120
|
+
gotOptions.headers = Object.assign({
|
|
121
|
+
"authorization": "Bearer " + this.#apiToken,
|
|
122
|
+
"user-agent": this.#userAgent
|
|
123
|
+
}, request.headers);
|
|
124
|
+
|
|
125
125
|
let response;
|
|
126
126
|
try {
|
|
127
127
|
if (request.hasOutputStream()) {
|
package/src/Request/Request.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const FormData = require('form-data');
|
|
2
1
|
const {createReadStream} = require('fs');
|
|
3
2
|
const {createWriteStream} = require("fs");
|
|
4
3
|
|
|
@@ -149,20 +148,8 @@ class Request {
|
|
|
149
148
|
return this.data;
|
|
150
149
|
}
|
|
151
150
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (!this.data.hasOwnProperty(key)) {
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
if (Array.isArray(this.data[key])) {
|
|
158
|
-
for (let element of this.data[key]) {
|
|
159
|
-
body.append(key + "[]", element);
|
|
160
|
-
}
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
body.append(key, this.data[key]);
|
|
164
|
-
}
|
|
165
|
-
return body;
|
|
151
|
+
this.setHeader("content-type", "application/json");
|
|
152
|
+
return JSON.stringify(this.data);
|
|
166
153
|
}
|
|
167
154
|
|
|
168
155
|
/**
|
|
@@ -2,6 +2,20 @@ const ServerRequest = require('./ServerRequest');
|
|
|
2
2
|
|
|
3
3
|
class StartServerRequest extends ServerRequest {
|
|
4
4
|
endpoint = "servers/{id}/start";
|
|
5
|
+
method = "POST";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* StartServerRequest constructor
|
|
9
|
+
*
|
|
10
|
+
* @param {string} id
|
|
11
|
+
* @param {boolean} useOwnCredits
|
|
12
|
+
*/
|
|
13
|
+
constructor(id, useOwnCredits = false) {
|
|
14
|
+
super(id);
|
|
15
|
+
this.data = {
|
|
16
|
+
useOwnCredits: useOwnCredits
|
|
17
|
+
};
|
|
18
|
+
}
|
|
5
19
|
}
|
|
6
20
|
|
|
7
21
|
module.exports = StartServerRequest;
|
package/src/Server/Server.js
CHANGED
|
@@ -149,11 +149,12 @@ class Server extends EventEmitter {
|
|
|
149
149
|
/**
|
|
150
150
|
* Start the server
|
|
151
151
|
*
|
|
152
|
+
* @param {boolean} useOwnCredits
|
|
152
153
|
* @return {Promise<Response>}
|
|
153
154
|
* @throws {RequestError}
|
|
154
155
|
*/
|
|
155
|
-
async start() {
|
|
156
|
-
return this.#client.request(new StartServerRequest(this.id));
|
|
156
|
+
async start(useOwnCredits = false) {
|
|
157
|
+
return this.#client.request(new StartServerRequest(this.id, useOwnCredits));
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
/**
|