exaroton 1.8.1 → 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.
@@ -7,12 +7,16 @@ on:
7
7
  jobs:
8
8
  publish-npm:
9
9
  runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: read
12
+ id-token: write
10
13
  steps:
11
14
  - uses: actions/checkout@v3
12
15
  - uses: actions/setup-node@v3
13
16
  with:
14
17
  node-version: 16
15
18
  registry-url: https://registry.npmjs.org/
19
+ - run: npm install -g npm
16
20
  - run: npm ci
17
21
  - run: npm publish --provenance --access public
18
22
  env:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exaroton",
3
- "version": "1.8.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()) {
@@ -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
- let body = new FormData();
153
- for (let key in this.data) {
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;
@@ -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
  /**