Skip to content
This repository has been archived by the owner on Nov 23, 2022. It is now read-only.

Add a code to customize the key. #92

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open

Conversation

fj2008
Copy link

@fj2008 fj2008 commented Mar 14, 2022

I'm using the library well.
But I wanted the developer to set the key value.
I try it on the company project and pull request it because it's good.
I look forward to your kind cooperation.

If possible, please review the code... Thanks you!!

onur-ozkan and others added 5 commits December 1, 2021 11:21
* Adding getIpFromRequest method to get the request's IP (onur-ozkan#84)

* upgrade to v3.1.0

Co-authored-by: Oleksandr Bordun <[email protected]>
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.13.3 to 1.14.9.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](follow-redirects/follow-redirects@v1.13.3...v1.14.9)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](node-fetch/node-fetch@v2.6.1...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Copy link
Author

@fj2008 fj2008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use it as follows.
@RateLimit({ keyPrefix: 'sign-up', keyFactory: (req: Request) => { return 'hello rate-limiter'; }, duration: 60, errorMessage: 'Accounts cannot be created more than once in per minute', }) @Get('/rate/test') public async rateLimiterTest() { return 'hello'; }
Returns the result value of the keyFactory function.
The key value can be modified by the developer through the return value.

@onur-ozkan
Copy link
Owner

Thank you for the PR!. It looks very useful, but I wonder if this works also for Fastify. Since we don't have the 'express' dependency in this project why you imported it here?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants