From 1325784007d4c7fbe2258447ae40b9ecf350d75b Mon Sep 17 00:00:00 2001 From: jean Date: Wed, 10 Jul 2024 09:18:05 +0200 Subject: [PATCH 1/5] docs: indicates to run a redis instance --- .gitignore | 3 +++ README.md | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.gitignore b/.gitignore index 51a26f2..7f4c8d7 100644 --- a/.gitignore +++ b/.gitignore @@ -153,3 +153,6 @@ yarn.lock # redis dump.rdb + +# docker-compose to test in local +docker-compose.yml diff --git a/README.md b/README.md index 3fa910a..4dfb72e 100644 --- a/README.md +++ b/README.md @@ -435,6 +435,20 @@ The response will have the following headers if `enableDraftSpec` is `true`: |`ratelimit-reset` | how many seconds must pass before the rate limit resets |`retry-after` | contains the same value in time as `ratelimit-reset` +### Contribute +To run tests locally, you need a Redis instance. +Here's a sample `docker-compose.yml` file to run Redis in your local environment: + +```yaml +version: '3.8' + +services: + redis: + image: redis:latest + ports: + - "6379:6379" +``` + ## License **[MIT](https://github.com/fastify/fastify-rate-limit/blob/master/LICENSE)**
From c6a06a791bf978c0a062ce5858791e58c7eabc3e Mon Sep 17 00:00:00 2001 From: jean Date: Wed, 10 Jul 2024 09:20:20 +0200 Subject: [PATCH 2/5] refactor: defaultHook is always set in global params --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 3e5c4ab..6f1feeb 100644 --- a/index.js +++ b/index.js @@ -167,7 +167,7 @@ function mergeParams (...params) { } function addRouteRateHook (pluginComponent, params, routeOptions) { - const hook = params.hook || defaultHook + const hook = params.hook const hookHandler = rateLimitRequestHandler(pluginComponent, params) if (Array.isArray(routeOptions[hook])) { routeOptions[hook].push(hookHandler) From b3e5f1f3a836526191c8d7e079c3dd5108146447 Mon Sep 17 00:00:00 2001 From: jean Date: Wed, 10 Jul 2024 11:03:13 +0200 Subject: [PATCH 3/5] fix: command to launch redis already exist --- .gitignore | 3 --- README.md | 15 ++++----------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 7f4c8d7..51a26f2 100644 --- a/.gitignore +++ b/.gitignore @@ -153,6 +153,3 @@ yarn.lock # redis dump.rdb - -# docker-compose to test in local -docker-compose.yml diff --git a/README.md b/README.md index 4dfb72e..21e58b6 100644 --- a/README.md +++ b/README.md @@ -436,18 +436,11 @@ The response will have the following headers if `enableDraftSpec` is `true`: |`retry-after` | contains the same value in time as `ratelimit-reset` ### Contribute -To run tests locally, you need a Redis instance. -Here's a sample `docker-compose.yml` file to run Redis in your local environment: - -```yaml -version: '3.8' - -services: - redis: - image: redis:latest - ports: - - "6379:6379" +To run tests locally, you need a Redis instance that you can launch with this command: ``` +npm run redis +``` + ## License From 86de0485ffb3a854112f1e263cc1acc7d9928412 Mon Sep 17 00:00:00 2001 From: jean Date: Wed, 10 Jul 2024 11:04:27 +0200 Subject: [PATCH 4/5] fix: remove blank line --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 21e58b6..0a288cf 100644 --- a/README.md +++ b/README.md @@ -441,7 +441,6 @@ To run tests locally, you need a Redis instance that you can launch with this co npm run redis ``` - ## License **[MIT](https://github.com/fastify/fastify-rate-limit/blob/master/LICENSE)**
From a495c158e88a12f7dcffb3e61ad23b4288328a5e Mon Sep 17 00:00:00 2001 From: jean Date: Wed, 10 Jul 2024 12:27:03 +0200 Subject: [PATCH 5/5] test: remove coverage limit --- .taprc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.taprc b/.taprc index 26feaa7..4a042d4 100644 --- a/.taprc +++ b/.taprc @@ -1,9 +1,4 @@ jobs: 1 -branches: 96 -functions: 100 -lines: 100 -statements: 98 - files: - test/**/*.test.js