@k03mad/ip2geo 19.4.0 β†’ 20.1.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.
Files changed (42) hide show
  1. package/.vscode/settings.json +2 -1
  2. package/api.js +13 -0
  3. package/app/api.ts +120 -0
  4. package/app/cli.ts +102 -0
  5. package/app/helpers/cache.ts +257 -0
  6. package/app/helpers/utils.ts +1 -0
  7. package/app/types.ts +15 -0
  8. package/cli.js +3 -0
  9. package/package.json +13 -10
  10. package/pnpm-workspace.yaml +4 -2
  11. package/tests/cache-file-entries.ts +37 -0
  12. package/tests/cache-file-modify.ts +34 -0
  13. package/tests/cache-file-subfolder.ts +34 -0
  14. package/tests/cache-map-entries.ts +41 -0
  15. package/tests/cache-map-max-entries.ts +50 -0
  16. package/tests/cache-map-off.ts +34 -0
  17. package/tests/default.ts +55 -0
  18. package/tests/helpers/path.ts +5 -0
  19. package/tests/ip-multi-requests-cache.ts +39 -0
  20. package/tests/ip-no-data.ts +33 -0
  21. package/tests/ip-v6.ts +31 -0
  22. package/tests/shared/consts.ts +49 -0
  23. package/tests/shared/fs.ts +44 -0
  24. package/tsconfig.json +9 -0
  25. package/app/api.js +0 -142
  26. package/app/cli.js +0 -104
  27. package/app/helpers/cache.js +0 -274
  28. package/app/helpers/utils.js +0 -2
  29. package/tests/cache-file-entries.js +0 -37
  30. package/tests/cache-file-modify.js +0 -34
  31. package/tests/cache-file-subfolder.js +0 -34
  32. package/tests/cache-map-entries.js +0 -41
  33. package/tests/cache-map-max-entries.js +0 -50
  34. package/tests/cache-map-off.js +0 -35
  35. package/tests/default.js +0 -55
  36. package/tests/helpers/path.js +0 -13
  37. package/tests/ip-multi-requests-cache.js +0 -39
  38. package/tests/ip-no-data.js +0 -35
  39. package/tests/ip-v6.js +0 -31
  40. package/tests/shared/consts.js +0 -47
  41. package/tests/shared/fs.js +0 -42
  42. /package/app/helpers/{colors.js β†’ colors.ts} +0 -0
@@ -1,47 +0,0 @@
1
- export const REQUEST_IPV4 = {
2
- ip: '8.8.8.8',
3
- continent: 'North America',
4
- continentCode: 'NA',
5
- country: 'United States',
6
- countryCode: 'US',
7
- countryEmoji: 'πŸ‡ΊπŸ‡Έ',
8
- region: 'California',
9
- regionCode: 'CA',
10
- city: 'Mountain View',
11
- connectionAsn: 15_169,
12
- connectionOrg: 'Google LLC',
13
- connectionIsp: 'Google LLC',
14
- connectionDomain: 'google.com',
15
- };
16
-
17
- export const REQUEST_IPV4_MAP_OFF_ONLY = {
18
- ip: '9.9.9.9',
19
- continent: 'North America',
20
- continentCode: 'NA',
21
- country: 'United States',
22
- countryCode: 'US',
23
- countryEmoji: 'πŸ‡ΊπŸ‡Έ',
24
- region: 'California',
25
- regionCode: 'CA',
26
- city: 'Berkeley',
27
- connectionAsn: 19_281,
28
- connectionOrg: 'Quad',
29
- connectionIsp: 'Quad',
30
- connectionDomain: 'quad9.net',
31
- };
32
-
33
- export const REQUEST_IPV6 = {
34
- ip: '2a00:dd80:40:100::',
35
- continent: 'North America',
36
- continentCode: 'NA',
37
- country: 'United States',
38
- countryCode: 'US',
39
- countryEmoji: 'πŸ‡ΊπŸ‡Έ',
40
- region: 'District of Columbia',
41
- regionCode: 'DC',
42
- city: 'Washington',
43
- connectionAsn: 36_236,
44
- connectionOrg: 'Netactuate INC',
45
- connectionIsp: 'Netactuate, INC',
46
- connectionDomain: 'netactuate.com',
47
- };
@@ -1,42 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import fs from 'node:fs/promises';
3
- import path from 'node:path';
4
-
5
- import {
6
- DEFAULT_CACHE_FILE_DIR,
7
- DEFAULT_CACHE_FILE_NAME,
8
- DEFAULT_CACHE_FILE_NEWLINE,
9
- DEFAULT_CACHE_FILE_SEPARATOR,
10
- } from '../../app/api.js';
11
-
12
- /** @param {string} cacheDir */
13
- export const removeCacheFolder = async (cacheDir = DEFAULT_CACHE_FILE_DIR) => {
14
- try {
15
- await fs.rm(cacheDir, {recursive: true, force: true});
16
- } catch (err) {
17
- if (err.code !== 'ENOENT') {
18
- throw err;
19
- }
20
- }
21
- };
22
-
23
- /**
24
- * @param {object} opts
25
- * @param {string} opts.cacheDir
26
- * @param {string} opts.cacheFileName
27
- * @param {string} opts.cacheFileSeparator
28
- * @param {string} opts.cacheFileNewline
29
- * @param {object} opts.response
30
- */
31
- export const checkCacheFile = async ({
32
- cacheDir = DEFAULT_CACHE_FILE_DIR,
33
- cacheFileName = DEFAULT_CACHE_FILE_NAME,
34
- cacheFileSeparator = DEFAULT_CACHE_FILE_SEPARATOR,
35
- cacheFileNewline = DEFAULT_CACHE_FILE_NEWLINE,
36
- response,
37
- }) => {
38
- const cacheFile = `${response.ip.split(/[.:]/)[0]}_${cacheFileName}`;
39
- const data = await fs.readFile(path.join(cacheDir, cacheFile), {encoding: 'utf8'});
40
-
41
- assert.equal(data, cacheFileNewline + Object.values(response).join(cacheFileSeparator));
42
- };
File without changes