ipwhois 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # IPWhois Node Module
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/ipwhois.svg)](https://www.npmjs.com/package/ipwhois)
4
+ [![GitHub](https://img.shields.io/github/license/neutron92/ipwhois)](https://github.com/neutron92/ipwhois)
5
+ [![Node.js Version](https://img.shields.io/node/v/ipwhois)](https://nodejs.org)
6
+
3
7
  A lightweight Node.js module for fetching IP geolocation information using the [ipwhois.app](https://ipwhois.app) API.
4
8
 
5
9
  ## Features
@@ -14,8 +18,7 @@ A lightweight Node.js module for fetching IP geolocation information using the [
14
18
  ## Installation
15
19
 
16
20
  ```bash
17
- npm install
18
- npm run build
21
+ npm install ipwhois
19
22
  ```
20
23
 
21
24
  ## Usage
@@ -198,6 +201,10 @@ npm test
198
201
 
199
202
  MIT
200
203
 
204
+ ## Repository
205
+
206
+ [GitHub Repository](https://github.com/neutron92/ipwhois)
207
+
201
208
  ## Credits
202
209
 
203
210
  This module uses the [ipwhois.app](https://ipwhois.app) API.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IpWhoisResponse, IpWhoisOptions } from './types';
1
+ import { IpWhoisResponse, IpWhoisOptions } from "./types";
2
2
  /**
3
3
  * Fetches IP geolocation information from ipwhois.app API
4
4
  *
@@ -43,6 +43,6 @@ export declare function getIpInfo(ip: string, timeout?: number): Promise<IpWhois
43
43
  * ```
44
44
  */
45
45
  export declare function getMyIpInfo(timeout?: number): Promise<IpWhoisResponse>;
46
- export type { IpWhoisResponse, IpWhoisError, IpWhoisOptions } from './types';
46
+ export type { IpWhoisResponse, IpWhoisError, IpWhoisOptions } from "./types";
47
47
  export default ipwhois;
48
48
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAgB,cAAc,EAAE,MAAM,SAAS,CAAC;AAIxE;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CA+ChF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAEtF;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAE5E;AAGD,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG7E,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAgB,cAAc,EAAE,MAAM,SAAS,CAAC;AAIxE;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,OAAO,CAC3B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,eAAe,CAAC,CAgD1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,SAAS,CAC7B,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,CAAC,CAE1B;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAE5E;AAGD,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG7E,eAAe,OAAO,CAAC"}
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ipwhois = ipwhois;
4
4
  exports.getIpInfo = getIpInfo;
5
5
  exports.getMyIpInfo = getMyIpInfo;
6
- const BASE_URL = 'https://ipwhois.app/json';
6
+ const BASE_URL = "https://ipwhois.app/json";
7
7
  /**
8
8
  * Fetches IP geolocation information from ipwhois.app API
9
9
  *
@@ -30,12 +30,12 @@ async function ipwhois(options) {
30
30
  const timeoutId = setTimeout(() => controller.abort(), timeout);
31
31
  // Make request using native fetch (available in Node 20+)
32
32
  const response = await fetch(url, {
33
- method: 'GET',
33
+ method: "GET",
34
34
  headers: {
35
- 'Accept': 'application/json',
36
- 'User-Agent': 'ipwhois-node-module/1.0.0'
35
+ Accept: "application/json",
36
+ "User-Agent": "ipwhois-node-module/1.0.0",
37
37
  },
38
- signal: controller.signal
38
+ signal: controller.signal,
39
39
  });
40
40
  clearTimeout(timeoutId);
41
41
  // Check if response is ok
@@ -43,21 +43,21 @@ async function ipwhois(options) {
43
43
  throw new Error(`HTTP error! status: ${response.status}`);
44
44
  }
45
45
  // Parse JSON response
46
- const data = await response.json();
46
+ const data = (await response.json());
47
47
  // Check if the API returned an error
48
- if ('success' in data && data.success === false) {
49
- throw new Error(data.message || 'API returned an error');
48
+ if ("success" in data && data.success === false) {
49
+ throw new Error(data.message || "API returned an error");
50
50
  }
51
51
  return data;
52
52
  }
53
53
  catch (error) {
54
54
  if (error instanceof Error) {
55
- if (error.name === 'AbortError') {
55
+ if (error.name === "AbortError") {
56
56
  throw new Error(`Request timeout after ${timeout}ms`);
57
57
  }
58
58
  throw error;
59
59
  }
60
- throw new Error('Unknown error occurred');
60
+ throw new Error("Unknown error occurred");
61
61
  }
62
62
  }
63
63
  /**
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAoBA,0BA+CC;AAeD,8BAEC;AAcD,kCAEC;AAlGD,MAAM,QAAQ,GAAG,0BAA0B,CAAC;AAE5C;;;;;;;;;;;;;;;GAeG;AACI,KAAK,U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B,kBAAe,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ipwhois",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A Node.js module to fetch IP geolocation information from ipwhois.app API (not official).",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,6 +18,14 @@
18
18
  ],
19
19
  "author": "",
20
20
  "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/neutron92/ipwhois.git"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/neutron92/ipwhois/issues"
27
+ },
28
+ "homepage": "https://github.com/neutron92/ipwhois#readme",
21
29
  "engines": {
22
30
  "node": ">=22.0.0"
23
31
  },