feat: Add rate limiting middleware - #140
Conversation
- Implement token bucket and sliding window rate limiting algorithms - Add configurable middleware with Express.js-like API - Include comprehensive test coverage (18 tests passing) - Add examples and documentation - Support custom key generation, skip functions, and headers - Compatible with existing Pharaoh middleware system
- Fix import path and API usage for rate limiting example - Add proper dependency configuration in pubspec.yaml - Create comprehensive test script demonstrating all features - Verify rate limiting works with token bucket and sliding window - Test custom key generation, skip functionality, and headers
This commit applies consistent formatting, improves code readability, and fixes minor whitespace issues across rate limiting middleware, algorithms, and example/test files. No functional changes were made; the update is purely stylistic to enhance maintainability.
- Fix dart analyze warning for unused 'body' variable - Consume response body without storing in unused variable - All analysis checks now pass
codekeyz
commented
Sep 2, 2025
Looks good to me. @heyOnuoha Worth adding actual http tests that verify the rate limiting in action. |
heyOnuoha
commented
Sep 2, 2025
Got it @codekeyz, Will add that in |
- Create comprehensive HTTP tests that verify rate limiting in action - Test 429 responses, rate limit headers, and middleware behavior - Address maintainer feedback for actual HTTP verification - Include tests for custom key generation and skip functionality - All existing unit tests continue to pass (18 tests)
- Create focused HTTP test that verifies rate limiting in action - Test 429 responses, rate limit headers, and middleware behavior - Use Spookie framework following Pharaoh testing patterns - Remove complex HTTP client test attempts - All 22 tests now pass including HTTP integration tests - Addresses maintainer feedback for actual HTTP verification
Added new code coverage JSON reports for multiple test files across pharaoh, pharaoh_basic_auth, pharaoh_jwt_auth, pharaoh_rate_limit, spanner, and spookie packages. Removed the unused test_rate_limiting.dart from pharaoh_examples and updated rate_limit_http_test.dart in pharaoh_rate_limit.
codekeyz
left a comment
There was a problem hiding this comment.
I think you added some new files by mistake **.dart.vm.json
heyOnuoha
commented
Sep 4, 2025
Yes, that file was generated by the coverate script |
codekeyz
commented
Sep 4, 2025
You'll need to remove them. We don't need them aded to the repo. |
heyOnuoha
commented
Sep 4, 2025
Alright got it, I'll take them out |
Deleted multiple .vm.json files containing test coverage data from various package directories. This cleanup likely prepares for regeneration of coverage reports or reduces repository size by removing generated artifacts.
codekeyz
commented
Sep 11, 2025
Looks good to me, I'll merge now ✅ |
Uh oh!
There was an error while loading. Please reload this page.
Description
This PR adds a Rate Limiting Middleware to pharaoh middlewares.
Type of Change