ac-geoip 3.0.0 → 3.0.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.
@@ -0,0 +1,36 @@
1
+ # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+ # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3
+
4
+ name: Node.js CI
5
+
6
+ on:
7
+ push:
8
+ branches: [ master ]
9
+ pull_request:
10
+ branches: [ master ]
11
+
12
+ jobs:
13
+ build:
14
+
15
+ runs-on: ubuntu-latest
16
+
17
+ strategy:
18
+ matrix:
19
+ node-version: [16.x, 18.x]
20
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21
+ redis-version: [6]
22
+
23
+ steps:
24
+ - uses: actions/checkout@v3
25
+ - name: Use Node.js ${{ matrix.node-version }}
26
+ uses: actions/setup-node@v3
27
+ with:
28
+ node-version: ${{ matrix.node-version }}
29
+
30
+ - name: Start Redis
31
+ uses: supercharge/redis-github-action@1.4.0
32
+ with:
33
+ redis-version: ${{ matrix.redis-version }}
34
+
35
+ - run: yarn install
36
+ - run: yarn run test
package/.ncurc.js ADDED
@@ -0,0 +1,7 @@
1
+ // List packages for minor updates
2
+ const minorUpdatePackages = ['chai']
3
+ module.exports = {
4
+ target: packageName => {
5
+ return minorUpdatePackages.includes(packageName) ? 'minor' : 'latest'
6
+ }
7
+ }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,38 @@
1
+ <a name="3.0.2"></a>
2
+
3
+ ## [3.0.2](https://github.com/admiralcloud/ac-geoip/compare/v3.0.1..v3.0.2) (2024-02-26 07:45:31)
4
+
5
+
6
+ ### Bug Fix
7
+
8
+ * **App:** Package updates | MP | [e6ab5710fa897109578b6f640fabde9773b3cc56](https://github.com/admiralcloud/ac-geoip/commit/e6ab5710fa897109578b6f640fabde9773b3cc56)
9
+ Package updates
10
+ Related issues: [undefined/undefined#master](undefined/browse/master)
11
+ <a name="3.0.1"></a>
12
+
13
+ ## [3.0.1](https://github.com/admiralcloud/ac-geoip/compare/v3.0.0..v3.0.1) (2023-07-26 06:14:56)
14
+
15
+
16
+ ### Bug Fix
17
+
18
+ * **App:** Make cacheTime for NodeCache configurable | MP | [89a63cbf3ae6e1bbcc277bd1cd45348c314c9080](https://github.com/admiralcloud/ac-geoip/commit/89a63cbf3ae6e1bbcc277bd1cd45348c314c9080)
19
+ Make cacheTime for NodeCache configurable. It still defaults to 7 days.
20
+ Related issues: [/issues#undefined](https://github.com//issues/undefined)
21
+ ### Documentation
22
+
23
+ * **App:** Added status badge from Github aciton | MP | [1b71085160da67310dc568e981625a3ca5a2efa0](https://github.com/admiralcloud/ac-geoip/commit/1b71085160da67310dc568e981625a3ca5a2efa0)
24
+ Added status badge from Github action
25
+ Related issues: [undefined/undefined#master](undefined/browse/master)
26
+ ### Chores
27
+
28
+ * **App:** Updated packages | MP | [49d773010e3cb55ccdf0c6de6f9a9e8af17974fa](https://github.com/admiralcloud/ac-geoip/commit/49d773010e3cb55ccdf0c6de6f9a9e8af17974fa)
29
+ Updated packages
30
+ Related issues: [/issues#undefined](https://github.com//issues/undefined)
31
+ ### Chores
32
+
33
+ * **App:** Added Github action for automated testing | MP | [2302e4a9c71c67ba2caa2ce89fa03e1a1a0c1459](https://github.com/admiralcloud/ac-geoip/commit/2302e4a9c71c67ba2caa2ce89fa03e1a1a0c1459)
34
+ Added Github action for automated testing
35
+ Related issues: [undefined/undefined#master](undefined/browse/master)
1
36
  <a name="3.0.0"></a>
2
37
 
3
38
  # [3.0.0](https://github.com/admiralcloud/ac-geoip/compare/v2.0.0..v3.0.0) (2022-12-18 08:36:22)
package/README.md CHANGED
@@ -5,6 +5,8 @@ GEOIP web service requires an account at Maxmind.
5
5
 
6
6
  You can also use the Geolite2 database from Maxmind: https://dev.maxmind.com/geoip/geoip2/geolite2/
7
7
 
8
+ [![Node.js CI](https://github.com/AdmiralCloud/ac-geoip/actions/workflows/node.js.yml/badge.svg)](https://github.com/AdmiralCloud/ac-geoip/actions/workflows/node.js.yml)
9
+
8
10
  ## Usage
9
11
 
10
12
  ### Using Webservice
package/index.js CHANGED
@@ -6,7 +6,6 @@ const WebServiceClient = require('@maxmind/geoip2-node').WebServiceClient
6
6
  const Reader = require('@maxmind/geoip2-node').Reader
7
7
 
8
8
  const NodeCache = require("node-cache")
9
- const geoCache = new NodeCache({ stdTTL: 7 * 86400, checkperiod: 3600 })
10
9
 
11
10
  const acgeoip = () => {
12
11
 
@@ -50,6 +49,11 @@ const acgeoip = () => {
50
49
  geoip.geolite.reader = geoipReader
51
50
  })
52
51
  }
52
+
53
+ if (!_.has(params, 'redis')) {
54
+ geoip.geoCache = new NodeCache({ stdTTL: _.get(geoip, 'cacheTime'), checkperiod: 3600 })
55
+ }
56
+
53
57
  }
54
58
 
55
59
  const lookupLocal = async (params) => {
@@ -222,13 +226,13 @@ const acgeoip = () => {
222
226
  const geoipResponse = _.get(params, 'geoipResponse')
223
227
  const ip = _.get(params, 'ip')
224
228
  const storageKey = _.get(geoip, 'environment') + ':geoip:' + ip
225
- geoCache.set(storageKey, geoipResponse)
229
+ geoip.geoCache.set(storageKey, geoipResponse)
226
230
  }
227
231
 
228
232
  const getFromMemory = (params) => {
229
233
  const ip = _.get(params, 'ip')
230
234
  const storageKey = _.get(geoip, 'environment') + ':geoip:' + ip
231
- return geoCache.get(storageKey)
235
+ return geoip.geoCache.get(storageKey)
232
236
  }
233
237
 
234
238
  const checkRedis = async (params) => {
package/package.json CHANGED
@@ -3,19 +3,19 @@
3
3
  "author": "Mark Poepping (https://www.admiralcloud.com)",
4
4
  "license": "MIT",
5
5
  "repository": "admiralcloud/ac-geoip",
6
- "version": "3.0.0",
6
+ "version": "3.0.2",
7
7
  "dependencies": {
8
- "@maxmind/geoip2-node": "^3.5.0",
9
- "ip": "^1.1.8",
8
+ "@maxmind/geoip2-node": "^5.0.0",
9
+ "ip": "^2.0.1",
10
10
  "lodash": "^4.17.21",
11
11
  "node-cache": "^5.1.2"
12
12
  },
13
13
  "devDependencies": {
14
- "ac-semantic-release": "^0.3.4",
15
- "chai": "^4.3.7",
16
- "eslint": "^8.30.0",
17
- "ioredis": "^5.2.4",
18
- "mocha": "^10.2.0"
14
+ "ac-semantic-release": "^0.4.2",
15
+ "chai": "^4.4.1",
16
+ "eslint": "^8.57.0",
17
+ "ioredis": "^5.3.2",
18
+ "mocha": "^10.3.0"
19
19
  },
20
20
  "scripts": {
21
21
  "test": "./node_modules/.bin/mocha --bail --exit --slow 1000 ./test/test.js || :"