Extract shared createRateLimiter factory - #1141
Conversation
|
the factory itself is verified good (both limiter configs preserved exactly, overrides still possible via spread order), but the branch went conflicting after #1161 merged its own copies of the main CI fixes. please rebase onto current main (git fetch origin && git rebase origin/main && git push --force-with-lease), dropping your duplicated copies of those fixes, and this merges. while you are in there, two optional tidy-ups: the stray double blank lines in app.ts and where workerId was removed in soroban-event-worker.ts, and consider moving the admin ipKeyGenerator change to its own PR since it belongs to a different issue. if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0 |
3dcf43d to
2484f8c
Compare
done |
Description
This PR addresses issue #1099 by extracting a shared
createRateLimiter(options)factory. This consolidates the standard rate limiter configuration into a single location so that bothglobalRateLimiterandstreamCreationRateLimiteruse a uniform setup. This prevents duplication and ensures any future bug fixes or config updates (such as a Redis store setup or IP-keying fixes) will apply consistently to all rate limiters without needing manual syncing across multiple files.Type of Change
Related Issues
Closes #1099
Changes Made
createRateLimiter(options)factory inbackend/src/middleware/rate-limiter.middleware.tsthat includes the shared base config (standardHeaders,legacyHeaders).globalRateLimiterto utilize this new factory instead of a rawrateLimit()call.createRateLimiterinbackend/src/middleware/stream-rate-limiter.middleware.tsfor thecreateStreamRateLimiterfactory.Testing
Test Coverage
Test Steps
Checklist
Additional Notes
This PR specifically focuses on the refactoring requested in the issue. Fixing the trust-proxy IP-keying issue itself and switching rate-limit backends are out of scope for this change and will be addressed in separate PRs/issues as tracked.