Skip to content

Feat/weighted rate limiting#16

Merged
thetutlage merged 2 commits intoadonisjs:3.xfrom
MaximeMRF:feat/weighted-rate-limiting
Mar 13, 2026
Merged

Feat/weighted rate limiting#16
thetutlage merged 2 commits intoadonisjs:3.xfrom
MaximeMRF:feat/weighted-rate-limiting

Conversation

@MaximeMRF
Copy link
Copy Markdown
Contributor

🔗 Linked issue

#15

❓ Type of change

  • [x ] ✨ New feature (a non-breaking change that adds functionality)

📚 Description

This PR introduces the ability to pass a custom amount to the increment, consume, and decrement methods of the Limiter.

I'm developing a security/WAF package for AdonisJS. This feature allows for a scoring-based system where different security threats (e.g., path traversal vs. simple 404) can carry different "weights" or penalties.

For the amount parameter, I have currently implemented a fail-safe approach: if a user provides a value <= 0, it defaults to 1.

  • Should we keep this fail-safe (silent fallback to 1)?

  • Or should we throw a Exception to alert the developer that they are passing invalid data?

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

I will update the doc if the PR is accepted, no worries

@thetutlage thetutlage merged commit 55fdbc1 into adonisjs:3.x Mar 13, 2026
5 checks passed
@thetutlage
Copy link
Copy Markdown
Member

Looks good. Thanks 👍🏽

Also, automatically falling back to a default amount does make sense, instead of throwing an exception.

@thetutlage
Copy link
Copy Markdown
Member

Please send a PR for the docs 🙏

@MaximeMRF
Copy link
Copy Markdown
Contributor Author

thanks, I will do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants