Compare commits

...

13 Commits

Author SHA1 Message Date
dependabot[bot] 39ff9ef4fe Bump express from 4.17.1 to 4.17.3
Bumps [express](https://github.com/expressjs/express) from 4.17.1 to 4.17.3.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.17.1...4.17.3)

---
updated-dependencies:
- dependency-name: express
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-11 06:27:53 +00:00
Klemek ab23e4aa3c Create docker.yml 2021-06-09 15:34:57 +02:00
Klemek ab573f91ee Merge pull request #58 from Klemek/f-stats-all
/stats?all=true
2021-04-06 10:10:00 +02:00
Klemek 8a9b9cdcfe /stats?all=true 2021-04-06 09:58:51 +02:00
Klemek e56867a269 Update bot_detector.js 2021-04-04 23:33:59 +02:00
Klemek 8e795c6371 Merge pull request #57 from Klemek/f-ignore-bots
ignore bots in hit counter
2021-04-04 23:31:38 +02:00
Klemek c3e53c7df8 more unit tests 2021-04-04 23:24:33 +02:00
Klemek 404b02830d unit testing 2021-04-04 22:48:21 +02:00
Klemek 2fe9a8fecd updated package.json 2021-04-04 21:57:54 +02:00
Klemek 078f3d7416 updated readme 2021-04-04 21:57:16 +02:00
Klemek d69e10202c bot detector handling requests and disabling hit counter 2021-04-04 21:57:09 +02:00
Klemek 140e472e29 bot detector base code 2021-04-04 21:56:39 +02:00
Klemek 823d97f4bb parseInt redis values 2021-03-30 20:19:37 +02:00
12 changed files with 641 additions and 269 deletions
+34
View File
@@ -0,0 +1,34 @@
name: Docker
on: ["push", "pull_request"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: false
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
+1
View File
@@ -2,6 +2,7 @@
/node_modules /node_modules
/config.json /config.json
/config.example.json /config.example.json
/robots_list.json
/data /data
/data/* /data/*
/test_data /test_data
+5
View File
@@ -336,6 +336,11 @@ Any URL like `/year/month/day/anything/` will redirect to this article (and link
* `hit_counter` * `hit_counter`
* `unique_visitor_timeout`: (default: 7200000 / 2h) * `unique_visitor_timeout`: (default: 7200000 / 2h)
specify the time (in ms) before a visitor can be accounted again specify the time (in ms) before a visitor can be accounted again
* `robots`
* `list_url`: (default: https://raw.githubusercontent.com/atmire/COUNTER-Robots/master/COUNTER_Robots_list.json)
url to fetch for web crawlers patterns
* `list_file`: (default: robots_list.json)
file to store web crawlers patterns
* `redis` * `redis`
Options to connect to redis (see [redis options](https://github.com/NodeRedis/node-redis#options-object-properties) for more info) Options to connect to redis (see [redis options](https://github.com/NodeRedis/node-redis#options-object-properties) for more info)
* `host`: (default: localhost) * `host`: (default: localhost)
+248 -193
View File
@@ -1,18 +1,18 @@
{ {
"name": "gitblog.md", "name": "gitblog.md",
"version": "1.2.8", "version": "1.3.3",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"version": "1.2.8", "version": "1.3.3",
"hasInstallScript": true, "hasInstallScript": true,
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@iarna/toml": "^2.2.3", "@iarna/toml": "^2.2.3",
"body-parser": "^1.19.0", "body-parser": "^1.19.0",
"ejs": "^3.1.6", "ejs": "^3.1.6",
"express": "^4.17.1", "express": "^4.17.3",
"express-rate-limit": "^5.0.0", "express-rate-limit": "^5.0.0",
"fa-diagrams": "^1.0.3", "fa-diagrams": "^1.0.3",
"mathjax-node": "^2.1.1", "mathjax-node": "^2.1.1",
@@ -840,12 +840,12 @@
"integrity": "sha512-1zSbbCuoIjafKZ3mblY5ikvAb0ODUbqBnFuUb7f6uLeQhhGJ0vEV4ntmtxKLT2WgXCO94E07BjunsIw1jOMPZw==" "integrity": "sha512-1zSbbCuoIjafKZ3mblY5ikvAb0ODUbqBnFuUb7f6uLeQhhGJ0vEV4ntmtxKLT2WgXCO94E07BjunsIw1jOMPZw=="
}, },
"node_modules/accepts": { "node_modules/accepts": {
"version": "1.3.7", "version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"dependencies": { "dependencies": {
"mime-types": "~2.1.24", "mime-types": "~2.1.34",
"negotiator": "0.6.2" "negotiator": "0.6.3"
}, },
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
@@ -1285,20 +1285,20 @@
} }
}, },
"node_modules/body-parser": { "node_modules/body-parser": {
"version": "1.19.0", "version": "1.19.2",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.2.tgz",
"integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", "integrity": "sha512-SAAwOxgoCKMGs9uUAUFHygfLAyaniaoun6I8mFY9pRAJL9+Kec34aU+oIjDhTycub1jozEfEwx1W1IuOYxVSFw==",
"dependencies": { "dependencies": {
"bytes": "3.1.0", "bytes": "3.1.2",
"content-type": "~1.0.4", "content-type": "~1.0.4",
"debug": "2.6.9", "debug": "2.6.9",
"depd": "~1.1.2", "depd": "~1.1.2",
"http-errors": "1.7.2", "http-errors": "1.8.1",
"iconv-lite": "0.4.24", "iconv-lite": "0.4.24",
"on-finished": "~2.3.0", "on-finished": "~2.3.0",
"qs": "6.7.0", "qs": "6.9.7",
"raw-body": "2.4.0", "raw-body": "2.4.3",
"type-is": "~1.6.17" "type-is": "~1.6.18"
}, },
"engines": { "engines": {
"node": ">= 0.8" "node": ">= 0.8"
@@ -1382,9 +1382,9 @@
"dev": true "dev": true
}, },
"node_modules/bytes": { "node_modules/bytes": {
"version": "3.1.0", "version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"engines": { "engines": {
"node": ">= 0.8" "node": ">= 0.8"
} }
@@ -1608,16 +1608,35 @@
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
}, },
"node_modules/content-disposition": { "node_modules/content-disposition": {
"version": "0.5.3", "version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"dependencies": { "dependencies": {
"safe-buffer": "5.1.2" "safe-buffer": "5.2.1"
}, },
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/content-disposition/node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
},
"node_modules/content-type": { "node_modules/content-type": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
@@ -1636,9 +1655,9 @@
} }
}, },
"node_modules/cookie": { "node_modules/cookie": {
"version": "0.4.0", "version": "0.4.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz",
"integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==", "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==",
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
} }
@@ -1917,7 +1936,7 @@
"node_modules/destroy": { "node_modules/destroy": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" "integrity": "sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg=="
}, },
"node_modules/detect-newline": { "node_modules/detect-newline": {
"version": "2.1.0", "version": "2.1.0",
@@ -2561,7 +2580,7 @@
"node_modules/etag": { "node_modules/etag": {
"version": "1.8.1", "version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
} }
@@ -2641,16 +2660,16 @@
} }
}, },
"node_modules/express": { "node_modules/express": {
"version": "4.17.1", "version": "4.17.3",
"resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", "resolved": "https://registry.npmjs.org/express/-/express-4.17.3.tgz",
"integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", "integrity": "sha512-yuSQpz5I+Ch7gFrPCk4/c+dIBKlQUxtgwqzph132bsT6qhuzss6I8cLJQz7B3rFblzd6wtcI0ZbGltH/C4LjUg==",
"dependencies": { "dependencies": {
"accepts": "~1.3.7", "accepts": "~1.3.8",
"array-flatten": "1.1.1", "array-flatten": "1.1.1",
"body-parser": "1.19.0", "body-parser": "1.19.2",
"content-disposition": "0.5.3", "content-disposition": "0.5.4",
"content-type": "~1.0.4", "content-type": "~1.0.4",
"cookie": "0.4.0", "cookie": "0.4.2",
"cookie-signature": "1.0.6", "cookie-signature": "1.0.6",
"debug": "2.6.9", "debug": "2.6.9",
"depd": "~1.1.2", "depd": "~1.1.2",
@@ -2664,13 +2683,13 @@
"on-finished": "~2.3.0", "on-finished": "~2.3.0",
"parseurl": "~1.3.3", "parseurl": "~1.3.3",
"path-to-regexp": "0.1.7", "path-to-regexp": "0.1.7",
"proxy-addr": "~2.0.5", "proxy-addr": "~2.0.7",
"qs": "6.7.0", "qs": "6.9.7",
"range-parser": "~1.2.1", "range-parser": "~1.2.1",
"safe-buffer": "5.1.2", "safe-buffer": "5.2.1",
"send": "0.17.1", "send": "0.17.2",
"serve-static": "1.14.1", "serve-static": "1.14.2",
"setprototypeof": "1.1.1", "setprototypeof": "1.2.0",
"statuses": "~1.5.0", "statuses": "~1.5.0",
"type-is": "~1.6.18", "type-is": "~1.6.18",
"utils-merge": "1.0.1", "utils-merge": "1.0.1",
@@ -2685,6 +2704,25 @@
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.0.0.tgz", "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.0.0.tgz",
"integrity": "sha512-dhT57wqxfqmkOi4HM7NuT4Gd7gbUgSK2ocG27Y6lwm8lbOAw9XQfeANawGq8wLDtlGPO1ZgDj0HmKsykTxfFAg==" "integrity": "sha512-dhT57wqxfqmkOi4HM7NuT4Gd7gbUgSK2ocG27Y6lwm8lbOAw9XQfeANawGq8wLDtlGPO1ZgDj0HmKsykTxfFAg=="
}, },
"node_modules/express/node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
]
},
"node_modules/extend": { "node_modules/extend": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
@@ -3072,9 +3110,9 @@
"dev": true "dev": true
}, },
"node_modules/forwarded": { "node_modules/forwarded": {
"version": "0.1.2", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=", "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
} }
@@ -3094,7 +3132,7 @@
"node_modules/fresh": { "node_modules/fresh": {
"version": "0.5.2", "version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
} }
@@ -4154,15 +4192,15 @@
} }
}, },
"node_modules/http-errors": { "node_modules/http-errors": {
"version": "1.7.2", "version": "1.8.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz",
"integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==",
"dependencies": { "dependencies": {
"depd": "~1.1.2", "depd": "~1.1.2",
"inherits": "2.0.3", "inherits": "2.0.4",
"setprototypeof": "1.1.1", "setprototypeof": "1.2.0",
"statuses": ">= 1.5.0 < 2", "statuses": ">= 1.5.0 < 2",
"toidentifier": "1.0.0" "toidentifier": "1.0.1"
}, },
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
@@ -4263,9 +4301,9 @@
} }
}, },
"node_modules/inherits": { "node_modules/inherits": {
"version": "2.0.3", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
}, },
"node_modules/invariant": { "node_modules/invariant": {
"version": "2.2.4", "version": "2.2.4",
@@ -4277,9 +4315,9 @@
} }
}, },
"node_modules/ipaddr.js": { "node_modules/ipaddr.js": {
"version": "1.9.0", "version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==", "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"engines": { "engines": {
"node": ">= 0.10" "node": ">= 0.10"
} }
@@ -6057,19 +6095,19 @@
} }
}, },
"node_modules/mime-db": { "node_modules/mime-db": {
"version": "1.40.0", "version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/mime-types": { "node_modules/mime-types": {
"version": "2.1.24", "version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dependencies": { "dependencies": {
"mime-db": "1.40.0" "mime-db": "1.52.0"
}, },
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
@@ -6178,9 +6216,9 @@
} }
}, },
"node_modules/negotiator": { "node_modules/negotiator": {
"version": "0.6.2", "version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
} }
@@ -6774,12 +6812,12 @@
} }
}, },
"node_modules/proxy-addr": { "node_modules/proxy-addr": {
"version": "2.0.5", "version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"dependencies": { "dependencies": {
"forwarded": "~0.1.2", "forwarded": "0.2.0",
"ipaddr.js": "1.9.0" "ipaddr.js": "1.9.1"
}, },
"engines": { "engines": {
"node": ">= 0.10" "node": ">= 0.10"
@@ -6809,11 +6847,14 @@
} }
}, },
"node_modules/qs": { "node_modules/qs": {
"version": "6.7.0", "version": "6.9.7",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz",
"integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw==",
"engines": { "engines": {
"node": ">=0.6" "node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/queue-microtask": { "node_modules/queue-microtask": {
@@ -6845,12 +6886,12 @@
} }
}, },
"node_modules/raw-body": { "node_modules/raw-body": {
"version": "2.4.0", "version": "2.4.3",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz",
"integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==",
"dependencies": { "dependencies": {
"bytes": "3.1.0", "bytes": "3.1.2",
"http-errors": "1.7.2", "http-errors": "1.8.1",
"iconv-lite": "0.4.24", "iconv-lite": "0.4.24",
"unpipe": "1.0.0" "unpipe": "1.0.0"
}, },
@@ -7403,9 +7444,9 @@
} }
}, },
"node_modules/send": { "node_modules/send": {
"version": "0.17.1", "version": "0.17.2",
"resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", "resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz",
"integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", "integrity": "sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww==",
"dependencies": { "dependencies": {
"debug": "2.6.9", "debug": "2.6.9",
"depd": "~1.1.2", "depd": "~1.1.2",
@@ -7414,9 +7455,9 @@
"escape-html": "~1.0.3", "escape-html": "~1.0.3",
"etag": "~1.8.1", "etag": "~1.8.1",
"fresh": "0.5.2", "fresh": "0.5.2",
"http-errors": "~1.7.2", "http-errors": "1.8.1",
"mime": "1.6.0", "mime": "1.6.0",
"ms": "2.1.1", "ms": "2.1.3",
"on-finished": "~2.3.0", "on-finished": "~2.3.0",
"range-parser": "~1.2.1", "range-parser": "~1.2.1",
"statuses": "~1.5.0" "statuses": "~1.5.0"
@@ -7426,19 +7467,19 @@
} }
}, },
"node_modules/send/node_modules/ms": { "node_modules/send/node_modules/ms": {
"version": "2.1.1", "version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
}, },
"node_modules/serve-static": { "node_modules/serve-static": {
"version": "1.14.1", "version": "1.14.2",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.2.tgz",
"integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", "integrity": "sha512-+TMNA9AFxUEGuC0z2mevogSnn9MXKb4fa7ngeRMJaaGv8vTwnIEkKi+QGvPt33HSnf8pRS+WGM0EbMtCJLKMBQ==",
"dependencies": { "dependencies": {
"encodeurl": "~1.0.2", "encodeurl": "~1.0.2",
"escape-html": "~1.0.3", "escape-html": "~1.0.3",
"parseurl": "~1.3.3", "parseurl": "~1.3.3",
"send": "0.17.1" "send": "0.17.2"
}, },
"engines": { "engines": {
"node": ">= 0.8.0" "node": ">= 0.8.0"
@@ -7477,9 +7518,9 @@
} }
}, },
"node_modules/setprototypeof": { "node_modules/setprototypeof": {
"version": "1.1.1", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
}, },
"node_modules/shebang-command": { "node_modules/shebang-command": {
"version": "1.2.0", "version": "1.2.0",
@@ -8389,9 +8430,9 @@
} }
}, },
"node_modules/toidentifier": { "node_modules/toidentifier": {
"version": "1.0.0", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"engines": { "engines": {
"node": ">=0.6" "node": ">=0.6"
} }
@@ -9558,12 +9599,12 @@
"integrity": "sha512-1zSbbCuoIjafKZ3mblY5ikvAb0ODUbqBnFuUb7f6uLeQhhGJ0vEV4ntmtxKLT2WgXCO94E07BjunsIw1jOMPZw==" "integrity": "sha512-1zSbbCuoIjafKZ3mblY5ikvAb0ODUbqBnFuUb7f6uLeQhhGJ0vEV4ntmtxKLT2WgXCO94E07BjunsIw1jOMPZw=="
}, },
"accepts": { "accepts": {
"version": "1.3.7", "version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
"integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
"requires": { "requires": {
"mime-types": "~2.1.24", "mime-types": "~2.1.34",
"negotiator": "0.6.2" "negotiator": "0.6.3"
} }
}, },
"acorn": { "acorn": {
@@ -9904,20 +9945,20 @@
} }
}, },
"body-parser": { "body-parser": {
"version": "1.19.0", "version": "1.19.2",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.2.tgz",
"integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", "integrity": "sha512-SAAwOxgoCKMGs9uUAUFHygfLAyaniaoun6I8mFY9pRAJL9+Kec34aU+oIjDhTycub1jozEfEwx1W1IuOYxVSFw==",
"requires": { "requires": {
"bytes": "3.1.0", "bytes": "3.1.2",
"content-type": "~1.0.4", "content-type": "~1.0.4",
"debug": "2.6.9", "debug": "2.6.9",
"depd": "~1.1.2", "depd": "~1.1.2",
"http-errors": "1.7.2", "http-errors": "1.8.1",
"iconv-lite": "0.4.24", "iconv-lite": "0.4.24",
"on-finished": "~2.3.0", "on-finished": "~2.3.0",
"qs": "6.7.0", "qs": "6.9.7",
"raw-body": "2.4.0", "raw-body": "2.4.3",
"type-is": "~1.6.17" "type-is": "~1.6.18"
} }
}, },
"brace-expansion": { "brace-expansion": {
@@ -9996,9 +10037,9 @@
"dev": true "dev": true
}, },
"bytes": { "bytes": {
"version": "3.1.0", "version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg=="
}, },
"cache-base": { "cache-base": {
"version": "1.0.1", "version": "1.0.1",
@@ -10183,11 +10224,18 @@
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
}, },
"content-disposition": { "content-disposition": {
"version": "0.5.3", "version": "0.5.4",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
"integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
"requires": { "requires": {
"safe-buffer": "5.1.2" "safe-buffer": "5.2.1"
},
"dependencies": {
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
}
} }
}, },
"content-type": { "content-type": {
@@ -10205,9 +10253,9 @@
} }
}, },
"cookie": { "cookie": {
"version": "0.4.0", "version": "0.4.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz",
"integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA=="
}, },
"cookie-signature": { "cookie-signature": {
"version": "1.0.6", "version": "1.0.6",
@@ -10429,7 +10477,7 @@
"destroy": { "destroy": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" "integrity": "sha512-3NdhDuEXnfun/z7x9GOElY49LoqVHoGScmOKwmxhsS8N5Y+Z8KyPPDnaSzqWgYt/ji4mqwfTS34Htrk0zPIXVg=="
}, },
"detect-newline": { "detect-newline": {
"version": "2.1.0", "version": "2.1.0",
@@ -10902,7 +10950,7 @@
"etag": { "etag": {
"version": "1.8.1", "version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg=="
}, },
"exec-sh": { "exec-sh": {
"version": "0.3.2", "version": "0.3.2",
@@ -10966,16 +11014,16 @@
} }
}, },
"express": { "express": {
"version": "4.17.1", "version": "4.17.3",
"resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", "resolved": "https://registry.npmjs.org/express/-/express-4.17.3.tgz",
"integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", "integrity": "sha512-yuSQpz5I+Ch7gFrPCk4/c+dIBKlQUxtgwqzph132bsT6qhuzss6I8cLJQz7B3rFblzd6wtcI0ZbGltH/C4LjUg==",
"requires": { "requires": {
"accepts": "~1.3.7", "accepts": "~1.3.8",
"array-flatten": "1.1.1", "array-flatten": "1.1.1",
"body-parser": "1.19.0", "body-parser": "1.19.2",
"content-disposition": "0.5.3", "content-disposition": "0.5.4",
"content-type": "~1.0.4", "content-type": "~1.0.4",
"cookie": "0.4.0", "cookie": "0.4.2",
"cookie-signature": "1.0.6", "cookie-signature": "1.0.6",
"debug": "2.6.9", "debug": "2.6.9",
"depd": "~1.1.2", "depd": "~1.1.2",
@@ -10989,17 +11037,24 @@
"on-finished": "~2.3.0", "on-finished": "~2.3.0",
"parseurl": "~1.3.3", "parseurl": "~1.3.3",
"path-to-regexp": "0.1.7", "path-to-regexp": "0.1.7",
"proxy-addr": "~2.0.5", "proxy-addr": "~2.0.7",
"qs": "6.7.0", "qs": "6.9.7",
"range-parser": "~1.2.1", "range-parser": "~1.2.1",
"safe-buffer": "5.1.2", "safe-buffer": "5.2.1",
"send": "0.17.1", "send": "0.17.2",
"serve-static": "1.14.1", "serve-static": "1.14.2",
"setprototypeof": "1.1.1", "setprototypeof": "1.2.0",
"statuses": "~1.5.0", "statuses": "~1.5.0",
"type-is": "~1.6.18", "type-is": "~1.6.18",
"utils-merge": "1.0.1", "utils-merge": "1.0.1",
"vary": "~1.1.2" "vary": "~1.1.2"
},
"dependencies": {
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
}
} }
}, },
"express-rate-limit": { "express-rate-limit": {
@@ -11326,9 +11381,9 @@
"dev": true "dev": true
}, },
"forwarded": { "forwarded": {
"version": "0.1.2", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow=="
}, },
"fragment-cache": { "fragment-cache": {
"version": "0.2.1", "version": "0.2.1",
@@ -11342,7 +11397,7 @@
"fresh": { "fresh": {
"version": "0.5.2", "version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q=="
}, },
"fs.realpath": { "fs.realpath": {
"version": "1.0.0", "version": "1.0.0",
@@ -12118,15 +12173,15 @@
} }
}, },
"http-errors": { "http-errors": {
"version": "1.7.2", "version": "1.8.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.8.1.tgz",
"integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", "integrity": "sha512-Kpk9Sm7NmI+RHhnj6OIWDI1d6fIoFAtFt9RLaTMRlg/8w49juAStsrBgp0Dp4OdxdVbRIeKhtCUvoi/RuAhO4g==",
"requires": { "requires": {
"depd": "~1.1.2", "depd": "~1.1.2",
"inherits": "2.0.3", "inherits": "2.0.4",
"setprototypeof": "1.1.1", "setprototypeof": "1.2.0",
"statuses": ">= 1.5.0 < 2", "statuses": ">= 1.5.0 < 2",
"toidentifier": "1.0.0" "toidentifier": "1.0.1"
} }
}, },
"http-signature": { "http-signature": {
@@ -12198,9 +12253,9 @@
} }
}, },
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
}, },
"invariant": { "invariant": {
"version": "2.2.4", "version": "2.2.4",
@@ -12212,9 +12267,9 @@
} }
}, },
"ipaddr.js": { "ipaddr.js": {
"version": "1.9.0", "version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="
}, },
"is-accessor-descriptor": { "is-accessor-descriptor": {
"version": "0.1.6", "version": "0.1.6",
@@ -13641,16 +13696,16 @@
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
}, },
"mime-db": { "mime-db": {
"version": "1.40.0", "version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="
}, },
"mime-types": { "mime-types": {
"version": "2.1.24", "version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"requires": { "requires": {
"mime-db": "1.40.0" "mime-db": "1.52.0"
} }
}, },
"minimatch": { "minimatch": {
@@ -13740,9 +13795,9 @@
"integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=" "integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M="
}, },
"negotiator": { "negotiator": {
"version": "0.6.2", "version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg=="
}, },
"neo-async": { "neo-async": {
"version": "2.6.1", "version": "2.6.1",
@@ -14214,12 +14269,12 @@
} }
}, },
"proxy-addr": { "proxy-addr": {
"version": "2.0.5", "version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"requires": { "requires": {
"forwarded": "~0.1.2", "forwarded": "0.2.0",
"ipaddr.js": "1.9.0" "ipaddr.js": "1.9.1"
} }
}, },
"psl": { "psl": {
@@ -14243,9 +14298,9 @@
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
}, },
"qs": { "qs": {
"version": "6.7.0", "version": "6.9.7",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.7.tgz",
"integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" "integrity": "sha512-IhMFgUmuNpyRfxA90umL7ByLlgRXu6tIfKPpF5TmcfRLlLCckfP/g3IQmju6jjpu+Hh8rA+2p6A27ZSPOOHdKw=="
}, },
"queue-microtask": { "queue-microtask": {
"version": "1.2.3", "version": "1.2.3",
@@ -14259,12 +14314,12 @@
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
}, },
"raw-body": { "raw-body": {
"version": "2.4.0", "version": "2.4.3",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.3.tgz",
"integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", "integrity": "sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g==",
"requires": { "requires": {
"bytes": "3.1.0", "bytes": "3.1.2",
"http-errors": "1.7.2", "http-errors": "1.8.1",
"iconv-lite": "0.4.24", "iconv-lite": "0.4.24",
"unpipe": "1.0.0" "unpipe": "1.0.0"
} }
@@ -14689,9 +14744,9 @@
"dev": true "dev": true
}, },
"send": { "send": {
"version": "0.17.1", "version": "0.17.2",
"resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", "resolved": "https://registry.npmjs.org/send/-/send-0.17.2.tgz",
"integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", "integrity": "sha512-UJYB6wFSJE3G00nEivR5rgWp8c2xXvJ3OPWPhmuteU0IKj8nKbG3DrjiOmLwpnHGYWAVwA69zmTm++YG0Hmwww==",
"requires": { "requires": {
"debug": "2.6.9", "debug": "2.6.9",
"depd": "~1.1.2", "depd": "~1.1.2",
@@ -14700,30 +14755,30 @@
"escape-html": "~1.0.3", "escape-html": "~1.0.3",
"etag": "~1.8.1", "etag": "~1.8.1",
"fresh": "0.5.2", "fresh": "0.5.2",
"http-errors": "~1.7.2", "http-errors": "1.8.1",
"mime": "1.6.0", "mime": "1.6.0",
"ms": "2.1.1", "ms": "2.1.3",
"on-finished": "~2.3.0", "on-finished": "~2.3.0",
"range-parser": "~1.2.1", "range-parser": "~1.2.1",
"statuses": "~1.5.0" "statuses": "~1.5.0"
}, },
"dependencies": { "dependencies": {
"ms": { "ms": {
"version": "2.1.1", "version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
} }
} }
}, },
"serve-static": { "serve-static": {
"version": "1.14.1", "version": "1.14.2",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.2.tgz",
"integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", "integrity": "sha512-+TMNA9AFxUEGuC0z2mevogSnn9MXKb4fa7ngeRMJaaGv8vTwnIEkKi+QGvPt33HSnf8pRS+WGM0EbMtCJLKMBQ==",
"requires": { "requires": {
"encodeurl": "~1.0.2", "encodeurl": "~1.0.2",
"escape-html": "~1.0.3", "escape-html": "~1.0.3",
"parseurl": "~1.3.3", "parseurl": "~1.3.3",
"send": "0.17.1" "send": "0.17.2"
} }
}, },
"set-blocking": { "set-blocking": {
@@ -14755,9 +14810,9 @@
} }
}, },
"setprototypeof": { "setprototypeof": {
"version": "1.1.1", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
}, },
"shebang-command": { "shebang-command": {
"version": "1.2.0", "version": "1.2.0",
@@ -15505,9 +15560,9 @@
} }
}, },
"toidentifier": { "toidentifier": {
"version": "1.0.0", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA=="
}, },
"tough-cookie": { "tough-cookie": {
"version": "2.5.0", "version": "2.5.0",
+2 -2
View File
@@ -1,13 +1,13 @@
{ {
"name": "gitblog.md", "name": "gitblog.md",
"version": "1.3.1", "version": "1.3.3",
"description": "A static blog using Markdown pulled from your git repository.", "description": "A static blog using Markdown pulled from your git repository.",
"main": "src/server.js", "main": "src/server.js",
"dependencies": { "dependencies": {
"@iarna/toml": "^2.2.3", "@iarna/toml": "^2.2.3",
"body-parser": "^1.19.0", "body-parser": "^1.19.0",
"ejs": "^3.1.6", "ejs": "^3.1.6",
"express": "^4.17.1", "express": "^4.17.3",
"express-rate-limit": "^5.0.0", "express-rate-limit": "^5.0.0",
"fa-diagrams": "^1.0.3", "fa-diagrams": "^1.0.3",
"mathjax-node": "^2.1.1", "mathjax-node": "^2.1.1",
+38 -2
View File
@@ -61,6 +61,23 @@ module.exports = (config) => {
} }
}, },
); );
const botDetector = require('./bot_detector')(config);
botDetector.load((status, err) => {
switch (status) {
case botDetector.status.FETCH_OK:
console.log(cons.ok, 'fetched robots list');
break;
case botDetector.status.FETCH_ERROR:
console.error(cons.error, 'error fetching robots list : ' + err);
break;
case botDetector.status.READ_OK:
console.log(cons.ok, `read robots list: ${botDetector.count}`);
break;
case botDetector.status.READ_ERROR:
console.error(cons.error, 'error reading robots list : ' + err);
break;
}
});
// set view engine from configuration // set view engine from configuration
app.set('view engine', config['view_engine']); app.set('view engine', config['view_engine']);
@@ -145,6 +162,9 @@ module.exports = (config) => {
}); });
app.use(limiter); app.use(limiter);
//detect robots
app.use(botDetector.handle);
//log request at result end //log request at result end
app.use((req, res, next) => { app.use((req, res, next) => {
if (config['access_log']) { if (config['access_log']) {
@@ -168,7 +188,7 @@ module.exports = (config) => {
if (err) { if (err) {
showError(req, res, 404); showError(req, res, 404);
} else { } else {
hc.count(req, '/', () => { hc.count(req, '/', req.isRobot, () => {
render(req, res, homePath, render(req, res, homePath,
{ {
articles: Object.values(articles) articles: Object.values(articles)
@@ -181,9 +201,25 @@ module.exports = (config) => {
}); });
app.get('/stats', (req, res) => { app.get('/stats', (req, res) => {
if (config['modules']['hit_counter']) { if (config['modules']['hit_counter']) {
if (req.query['all']) {
const keys = Object.keys(articles).filter(key => !articles[key].draft);
keys.unshift('/');
const read = (i, outputData) => {
if (i >= keys.length) {
res.json(outputData);
} else {
hc.read(keys[i], (data) => {
outputData.push(data);
read(i + 1, outputData);
});
}
};
read(0, []);
} else {
hc.read('/', (data) => { hc.read('/', (data) => {
res.json(data); res.json(data);
}); });
}
} else { } else {
showError(req, res, 404); showError(req, res, 404);
} }
@@ -271,7 +307,7 @@ module.exports = (config) => {
showError(req, res, 404); showError(req, res, 404);
} }
} else { } else {
hc.count(req, articlePath, () => { hc.count(req, articlePath, req.isRobot, () => {
renderer.render(article.realPath, (err, html) => { renderer.render(article.realPath, (err, html) => {
if (err) { if (err) {
console.log(cons.error, `failed to render article ${req.path} : ${err}`); console.log(cons.error, `failed to render article ${req.path} : ${err}`);
+66
View File
@@ -0,0 +1,66 @@
const https = require('https');
const fs = require('fs');
module.exports = (config) => {
const _this = {
status: {
FETCH_OK: 1,
FETCH_ERROR: 2,
READ_OK: 3,
READ_ERROR: 4,
},
count: [],
regex: null,
};
const fetchList = (cb) => {
https.get(config['robots']['list_url'], (res) => {
if (res.statusCode !== 200) {
cb(res.statusCode);
} else {
const file = fs.createWriteStream(config['robots']['list_file']);
res.pipe(file);
file.on('finish', () => {
file.close(cb);
});
}
}).on('error', (err) => {
cb(err.message);
});
};
const readFile = (cb) => {
fs.readFile(config['robots']['list_file'], { encoding: 'utf-8' }, (err, data) => {
if (err) {
cb(err, undefined);
} else {
try {
cb(undefined, JSON.parse(data));
} catch (err) {
cb(err, undefined);
}
}
});
};
_this.load = (cb) => {
fetchList((err) => {
cb(err ? _this.status.FETCH_ERROR : _this.status.FETCH_OK, err);
readFile((err, data) => {
if (!err) {
_this.count = data.length;
_this.regex = new RegExp('(' + data.filter(v => v['pattern']).map(v => v['pattern'])
.join('|') + ')');
}
cb(err ? _this.status.READ_ERROR : _this.status.READ_OK, err);
});
});
};
_this.handle = (req, res, next) => {
req.isRobot = !!((req.headers['user-agent'] || '').match(_this.regex));
next();
};
return _this;
};
+4
View File
@@ -63,6 +63,10 @@
"hit_counter": { "hit_counter": {
"unique_visitor_timeout": 7200000 "unique_visitor_timeout": 7200000
}, },
"robots": {
"list_url": "https://raw.githubusercontent.com/atmire/COUNTER-Robots/master/COUNTER_Robots_list.json",
"list_file": "robots_list.json"
},
"redis": { "redis": {
"host": "localhost", "host": "localhost",
"port": 6379 "port": 6379
+7 -5
View File
@@ -8,8 +8,8 @@ module.exports = (config, onConnect, onError) => {
const visitors = {}; const visitors = {};
const count = (req, path, cb) => { const count = (req, path, disable, cb) => {
if (!client.connected) { if (!client.connected || disable) {
cb(); cb();
} else { } else {
const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
@@ -42,15 +42,17 @@ module.exports = (config, onConnect, onError) => {
const read = (path, cb) => { const read = (path, cb) => {
if (!client.connected) { if (!client.connected) {
cb({ cb({
path: path,
hits: 0, hits: 0,
total_visitors: 0, total_visitors: 0,
current_visitors: 0, current_visitors: cleanVisitors(path),
}); });
} else { } else {
client.hgetall(path, (_, value) => { client.hgetall(path, (_, value) => {
cb({ cb({
hits: value ? value.h || 0 : 0, path: path,
total_visitors: value ? value.v || 0 : 0, hits: value ? parseInt(value.h) || 0 : 0,
total_visitors: value ? parseInt(value.v) || 0 : 0,
current_visitors: cleanVisitors(path), current_visitors: cleanVisitors(path),
}); });
}); });
+110 -57
View File
@@ -197,26 +197,6 @@ describe('Test root path', () => {
}); });
}, fail); }, fail);
}); });
test('404 index no stats', (done) => {
request(app).get('/stats')
.then((response) => {
expect(response.statusCode).toBe(404);
done();
});
});
test('200 index stats', (done) => {
config['modules']['hit_counter'] = true;
request(app).get('/stats')
.then((response) => {
expect(response.statusCode).toBe(200);
expect(response.body).toEqual({
hits: 0,
total_visitors: 0,
current_visitors: 0,
});
done();
});
});
}); });
describe('Test RSS feed', () => { describe('Test RSS feed', () => {
@@ -455,45 +435,8 @@ describe('Test articles rendering', () => {
}); });
}, fail); }, fail);
}); });
test('404 article no stats', (done) => {
utils.createEmptyDirs([ path.join(dataDir, '2019', '05', '05') ]);
utils.createEmptyFiles([
path.join(dataDir, '2019', '05', '05', 'index.md'),
path.join(dataDir, testTemplate),
]);
app.reload(() => {
request(app).get('/2019/05/05/hello/stats')
.then((response) => {
expect(response.statusCode).toBe(404);
done();
});
});
});
test('200 index stats', (done) => {
config['modules']['hit_counter'] = true;
utils.createEmptyDirs([ path.join(dataDir, '2019', '05', '05') ]);
utils.createEmptyFiles([
path.join(dataDir, '2019', '05', '05', 'index.md'),
path.join(dataDir, testTemplate),
]);
app.reload(() => {
request(app).get('/2019/05/05/anything/stats')
.then((response) => {
expect(response.statusCode).toBe(200);
expect(response.body).toEqual({
hits: 0,
total_visitors: 0,
current_visitors: 0,
});
done();
});
});
});
}); });
describe('Test static files', () => { describe('Test static files', () => {
test('404 invalid file no error page', (done) => { test('404 invalid file no error page', (done) => {
request(app).get('/somefile.txt') request(app).get('/somefile.txt')
@@ -574,3 +517,113 @@ describe('Test other requests', () => {
}); });
}); });
}); });
describe('Test stats', () => {
test('404 index no stats', (done) => {
request(app).get('/stats')
.then((response) => {
expect(response.statusCode).toBe(404);
done();
});
});
test('200 index stats', (done) => {
config['modules']['hit_counter'] = true;
request(app).get('/stats')
.then((response) => {
expect(response.statusCode).toBe(200);
expect(response.body).toEqual({
path: '/',
hits: 0,
total_visitors: 0,
current_visitors: 0,
});
done();
});
});
test('200 index stats all no article', (done) => {
config['modules']['hit_counter'] = true;
app.reload(() => {
request(app).get('/stats?all=true')
.then((response) => {
expect(response.statusCode).toBe(200);
expect(response.body).toEqual([
{
path: '/',
hits: 0,
total_visitors: 0,
current_visitors: 0,
},
]);
done();
});
});
});
test('200 index stats all 2 article 1 drafted', (done) => {
config['modules']['hit_counter'] = true;
utils.createEmptyDirs([
path.join(dataDir, '2019', '05', '05'),
path.join(dataDir, '2019', '04', '05'),
]);
utils.createEmptyFiles([
path.join(dataDir, '2019', '05', '05', 'index.md'),
path.join(dataDir, '2019', '04', '05', 'draft.md'),
]);
app.reload(() => {
request(app).get('/stats?all=true')
.then((response) => {
expect(response.statusCode).toBe(200);
expect(response.body).toEqual([
{
path: '/',
hits: 0,
total_visitors: 0,
current_visitors: 0,
},
{
path: '2019/05/05',
hits: 0,
total_visitors: 0,
current_visitors: 0,
},
]);
done();
});
});
});
test('404 article no stats', (done) => {
utils.createEmptyDirs([ path.join(dataDir, '2019', '05', '05') ]);
utils.createEmptyFiles([
path.join(dataDir, '2019', '05', '05', 'index.md'),
path.join(dataDir, testTemplate),
]);
app.reload(() => {
request(app).get('/2019/05/05/hello/stats')
.then((response) => {
expect(response.statusCode).toBe(404);
done();
});
});
});
test('200 article stats', (done) => {
config['modules']['hit_counter'] = true;
utils.createEmptyDirs([ path.join(dataDir, '2019', '05', '05') ]);
utils.createEmptyFiles([
path.join(dataDir, '2019', '05', '05', 'index.md'),
path.join(dataDir, testTemplate),
]);
app.reload(() => {
request(app).get('/2019/05/05/anything/stats')
.then((response) => {
expect(response.statusCode).toBe(200);
expect(response.body).toEqual({
path: '2019/05/05',
hits: 0,
total_visitors: 0,
current_visitors: 0,
});
done();
});
});
});
});
+116
View File
@@ -0,0 +1,116 @@
const fs = require('fs');
const utils = require('./test_utils');
const dataDir = 'test_data';
const config = {
robots: {
list_url: '',
list_file: `${dataDir}/robots_list.json`,
},
};
beforeAll(() => {
utils.deleteFolderSync(dataDir);
fs.mkdirSync(dataDir);
});
afterAll(() => {
if (fs.existsSync(dataDir)) {
utils.deleteFolderSync(dataDir);
}
});
const botDetector = require('../src/bot_detector')(config);
describe('load()', () => {
test('success', (done) => {
config.robots = {
list_url: 'https://raw.githubusercontent.com/atmire/COUNTER-Robots/master/COUNTER_Robots_list.json',
list_file: `${dataDir}/robots_list_success.json`,
};
let count = 0;
botDetector.load((status, err) => {
expect(err).not.toBeDefined();
expect(status).toBe(count === 0 ? botDetector.status.FETCH_OK : botDetector.status.READ_OK);
if (count > 0) {
done();
}
count++;
});
});
test('fetch and file failure', (done) => {
let count = 0;
config.robots = {
list_url: 'https://blog.klemek.fr/invalid.json',
list_file: `${dataDir}/robots_list_fail_1.json`,
};
botDetector.load((status) => {
expect(status).toBe(count === 0 ? botDetector.status.FETCH_ERROR : botDetector.status.READ_ERROR);
if (count > 0) {
done();
}
count++;
});
});
test('fetch failure and file ok', (done) => {
let count = 0;
config.robots = {
list_url: 'https://blog.klemek.fr/invalid.json',
list_file: `${dataDir}/robots_list_fail_2.json`,
};
fs.writeFile(config.robots.list_file, '[]\n', { encoding: 'utf-8' }, () => {
botDetector.load((status) => {
expect(status).toBe(count === 0 ? botDetector.status.FETCH_ERROR : botDetector.status.READ_OK);
if (count > 0) {
done();
}
count++;
});
});
});
});
describe('handle()', () => {
beforeAll((done) => {
config.robots = {
list_url: 'https://blog.klemek.fr/invalid.json',
list_file: `${dataDir}/robots_list_fake.json`,
};
fs.writeFile(config.robots.list_file, '[{"pattern":"bot"}]\n', { encoding: 'utf-8' }, () => {
botDetector.load((status) => {
if (status !== botDetector.status.FETCH_ERROR) {
done();
}
});
});
});
test('not bot', (done) => {
const req = {
headers: {
'user-agent': 'my user agent',
},
};
botDetector.handle(req, null, () => {
expect(req.isRobot).toBeFalsy();
done();
});
});
test('bot', (done) => {
const req = {
headers: {
'user-agent': 'bot',
},
};
botDetector.handle(req, null, () => {
expect(req.isRobot).toBeTruthy();
done();
});
});
});
+7 -7
View File
@@ -98,7 +98,7 @@ describe('read()', () => {
hc.count({ hc.count({
headers: {}, headers: {},
connection: { remoteAddress: 'test1' }, connection: { remoteAddress: 'test1' },
}, '/test/path/5', () => { }, '/test/path/5', false, () => {
hc.read('/test/path/5', (data) => { hc.read('/test/path/5', (data) => {
expect(data).toBeDefined(); expect(data).toBeDefined();
expect(data.current_visitors).toBe(1); expect(data.current_visitors).toBe(1);
@@ -111,7 +111,7 @@ describe('read()', () => {
hc.count({ hc.count({
headers: {}, headers: {},
connection: { remoteAddress: 'test1' }, connection: { remoteAddress: 'test1' },
}, '/test/path/5', () => { }, '/test/path/5', false, () => {
hc.read('/test/path/5', (data) => { hc.read('/test/path/5', (data) => {
expect(data).toBeDefined(); expect(data).toBeDefined();
expect(data.current_visitors).toBe(0); expect(data.current_visitors).toBe(0);
@@ -145,7 +145,7 @@ describe('count()', () => {
hc.count({ hc.count({
headers: {}, headers: {},
connection: { remoteAddress: 'test1' }, connection: { remoteAddress: 'test1' },
}, '/test/path/1', () => { }, '/test/path/1', false, () => {
expect(multiCalled).toBeTruthy(); expect(multiCalled).toBeTruthy();
expect(hincrbyCalls).toEqual([ expect(hincrbyCalls).toEqual([
[ [
@@ -177,11 +177,11 @@ describe('count()', () => {
hc.count({ hc.count({
headers: {}, headers: {},
connection: { remoteAddress: 'test2' }, connection: { remoteAddress: 'test2' },
}, '/test/path/2', () => { }, '/test/path/2', false, () => {
hc.count({ hc.count({
headers: {}, headers: {},
connection: { remoteAddress: 'test2' }, connection: { remoteAddress: 'test2' },
}, '/test/path/2', () => { }, '/test/path/2', false, () => {
expect(hincrbyCalls).toEqual([ expect(hincrbyCalls).toEqual([
[ [
'/test/path/2', '/test/path/2',
@@ -223,11 +223,11 @@ describe('count()', () => {
hc.count({ hc.count({
headers: {}, headers: {},
connection: { remoteAddress: 'test3' }, connection: { remoteAddress: 'test3' },
}, '/test/path/3', () => { }, '/test/path/3', false, () => {
hc.count({ hc.count({
headers: {}, headers: {},
connection: { remoteAddress: 'test3' }, connection: { remoteAddress: 'test3' },
}, '/test/path/3', () => { }, '/test/path/3', false, () => {
expect(hincrbyCalls).toEqual([ expect(hincrbyCalls).toEqual([
[ [
'/test/path/3', '/test/path/3',