zgrzyt 2.2.2 → 2.2.3
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/lib/check.js +2 -2
- package/lib/cloudflare.js +1 -6
- package/package.json +1 -1
package/lib/check.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
1
|
import http from 'node:http';
|
|
3
2
|
import https from 'node:https';
|
|
4
3
|
import makeDebug from 'debug';
|
|
@@ -8,11 +7,12 @@ const debug = makeDebug('zgrzyt:check');
|
|
|
8
7
|
import { resolve } from './dns.js';
|
|
9
8
|
import { updateHealth } from './state.js';
|
|
10
9
|
|
|
10
|
+
import packageJson from '../package.json' with { type: 'json' };
|
|
11
11
|
const {
|
|
12
12
|
name,
|
|
13
13
|
version,
|
|
14
14
|
homepage = 'https://github.com/pirxpilot/zgrzyt'
|
|
15
|
-
} =
|
|
15
|
+
} = packageJson;
|
|
16
16
|
|
|
17
17
|
const USER_AGENT = `${name}/${version} (${homepage})`;
|
|
18
18
|
|
package/lib/cloudflare.js
CHANGED
|
@@ -4,8 +4,6 @@ const debug = makeDebug('zgrzyt:cloudflare');
|
|
|
4
4
|
|
|
5
5
|
export default client;
|
|
6
6
|
|
|
7
|
-
/* global AbortController, fetch, URLSearchParams */
|
|
8
|
-
|
|
9
7
|
class CloudflareError extends Error {
|
|
10
8
|
constructor(errors) {
|
|
11
9
|
super(`Cloudflare API error: ${errors[0].message}`);
|
|
@@ -32,8 +30,6 @@ function makeFetch({ token, timeout, retry }) {
|
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
async function doFetch(method, command, { searchParams, json }) {
|
|
35
|
-
const controller = new AbortController();
|
|
36
|
-
const id = setTimeout(() => controller.abort(), timeout);
|
|
37
33
|
const url = new URL(command, 'https://api.cloudflare.com/client/v4/');
|
|
38
34
|
if (searchParams) {
|
|
39
35
|
url.search = new URLSearchParams(searchParams);
|
|
@@ -41,14 +37,13 @@ function makeFetch({ token, timeout, retry }) {
|
|
|
41
37
|
const options = {
|
|
42
38
|
method,
|
|
43
39
|
headers: { authorization },
|
|
44
|
-
signal:
|
|
40
|
+
signal: AbortSignal.timeout(timeout)
|
|
45
41
|
};
|
|
46
42
|
if (json) {
|
|
47
43
|
options.headers['Content-Type'] = 'application/json';
|
|
48
44
|
options.body = JSON.stringify(json);
|
|
49
45
|
}
|
|
50
46
|
const res = await fetch(url, options);
|
|
51
|
-
clearTimeout(id);
|
|
52
47
|
return res.json();
|
|
53
48
|
}
|
|
54
49
|
}
|