chapybara 0.6.1 → 0.6.2

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/index.js CHANGED
@@ -15,7 +15,7 @@ export class ChapybaraClient {
15
15
  }
16
16
 
17
17
  this.apiKey = options.apiKey;
18
- this.baseUrl = options.baseUrl || DEFAULT_BASE_URL;
18
+ this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/?$/, "/");
19
19
  this.retries = options.retries ?? DEFAULT_RETRIES;
20
20
  this.timeout = options.timeout || DEFAULT_TIMEOUT;
21
21
 
@@ -34,22 +34,22 @@ export class ChapybaraClient {
34
34
  }
35
35
 
36
36
  this.domain = {
37
- getIntelligence: (domain) => this._request(`/domain/${domain}`),
37
+ getIntelligence: (domain) => this._request(`domain/${domain}`),
38
38
  };
39
39
 
40
40
  this.ip = {
41
- getIntelligence: (ip) => this._request(`/ip/${ip}`),
41
+ getIntelligence: (ip) => this._request(`ip/${ip}`),
42
42
  };
43
43
 
44
44
  this.webtech = {
45
- getScanner: (domain) => this._request(`/webtech/${domain}`),
45
+ getScanner: (domain) => this._request(`webtech/${domain}`),
46
46
  };
47
47
 
48
48
  this.account = {
49
- getInfo: () => this._request("/account"),
49
+ getInfo: () => this._request("account"),
50
50
  };
51
51
 
52
- this.getUserIP = () => this._request("/ip");
52
+ this.getUserIP = () => this._request("ip");
53
53
  }
54
54
 
55
55
  async _request(endpoint, attempt = 1) {
package/lib/errors.js CHANGED
@@ -7,11 +7,12 @@ export class ChapybaraError extends Error {
7
7
 
8
8
  export class APIError extends ChapybaraError {
9
9
  constructor(status, error) {
10
- super(error?.error || `Request failed with status code ${status}`);
10
+ const msg = typeof error?.error === "string" ? error.error : error?.error?.message || error?.message || `Request failed with status code ${status}`;
11
+ super(msg);
11
12
  this.name = "APIError";
12
13
  this.status = status;
13
- this.code = error?.code;
14
- this.requestId = error?.requestId;
14
+ this.code = error?.error?.code || error?.code;
15
+ this.requestId = error?.error?.requestId || error?.requestId;
15
16
  }
16
17
  }
17
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chapybara",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Official NodeJS SDK for the Chapybara Domain & IP Intelligence API.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",