@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.
- package/.vscode/settings.json +2 -1
- package/api.js +13 -0
- package/app/api.ts +120 -0
- package/app/cli.ts +102 -0
- package/app/helpers/cache.ts +257 -0
- package/app/helpers/utils.ts +1 -0
- package/app/types.ts +15 -0
- package/cli.js +3 -0
- package/package.json +13 -10
- package/pnpm-workspace.yaml +4 -2
- package/tests/cache-file-entries.ts +37 -0
- package/tests/cache-file-modify.ts +34 -0
- package/tests/cache-file-subfolder.ts +34 -0
- package/tests/cache-map-entries.ts +41 -0
- package/tests/cache-map-max-entries.ts +50 -0
- package/tests/cache-map-off.ts +34 -0
- package/tests/default.ts +55 -0
- package/tests/helpers/path.ts +5 -0
- package/tests/ip-multi-requests-cache.ts +39 -0
- package/tests/ip-no-data.ts +33 -0
- package/tests/ip-v6.ts +31 -0
- package/tests/shared/consts.ts +49 -0
- package/tests/shared/fs.ts +44 -0
- package/tsconfig.json +9 -0
- package/app/api.js +0 -142
- package/app/cli.js +0 -104
- package/app/helpers/cache.js +0 -274
- package/app/helpers/utils.js +0 -2
- package/tests/cache-file-entries.js +0 -37
- package/tests/cache-file-modify.js +0 -34
- package/tests/cache-file-subfolder.js +0 -34
- package/tests/cache-map-entries.js +0 -41
- package/tests/cache-map-max-entries.js +0 -50
- package/tests/cache-map-off.js +0 -35
- package/tests/default.js +0 -55
- package/tests/helpers/path.js +0 -13
- package/tests/ip-multi-requests-cache.js +0 -39
- package/tests/ip-no-data.js +0 -35
- package/tests/ip-v6.js +0 -31
- package/tests/shared/consts.js +0 -47
- package/tests/shared/fs.js +0 -42
- /package/app/helpers/{colors.js β colors.ts} +0 -0
package/tests/shared/consts.js
DELETED
|
@@ -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
|
-
};
|
package/tests/shared/fs.js
DELETED
|
@@ -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
|