zgrzyt 2.2.2 → 2.2.4

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 CHANGED
@@ -1,10 +1,10 @@
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';
5
4
 
6
5
  const debug = makeDebug('zgrzyt:check');
7
6
 
7
+ import packageJson from '../package.json' with { type: 'json' };
8
8
  import { resolve } from './dns.js';
9
9
  import { updateHealth } from './state.js';
10
10
 
@@ -12,7 +12,7 @@ const {
12
12
  name,
13
13
  version,
14
14
  homepage = 'https://github.com/pirxpilot/zgrzyt'
15
- } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url)));
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: controller.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
  }
package/lib/config.js CHANGED
@@ -22,10 +22,10 @@ function prepareConfig(config) {
22
22
  return;
23
23
  }
24
24
  if (typeof cloudflare.timeout === 'string') {
25
- cloudflare.timeout = Number.parseInt(cloudflare.timeout);
25
+ cloudflare.timeout = Number.parseInt(cloudflare.timeout, 10);
26
26
  }
27
27
  if (typeof cloudflare.retry === 'string') {
28
- cloudflare.retry = Number.parseInt(cloudflare.retry);
28
+ cloudflare.retry = Number.parseInt(cloudflare.retry, 10);
29
29
  }
30
30
 
31
31
  // collect all APIs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zgrzyt",
3
- "version": "2.2.2",
3
+ "version": "2.2.4",
4
4
  "description": "Poor man's load balancing DNS switcher.",
5
5
  "type": "module",
6
6
  "author": {
@@ -32,7 +32,7 @@
32
32
  "sprintfjs": "^1.2.16"
33
33
  },
34
34
  "devDependencies": {
35
- "@biomejs/biome": "^1.9.4"
35
+ "@biomejs/biome": "2.2.5"
36
36
  },
37
37
  "scripts": {
38
38
  "test": "make check"