Skip to content

[Backend] backend/src/middleware/rate-limiter.middleware.ts and stream-rate-limiter.middleware.ts duplicate the same window/store setup logic #1099

Description

@grantfox-oss

Join our community: https://t.me/+DOylgFv1jyJlNzM0

Why this matters

backend/src/middleware/rate-limiter.middleware.ts and backend/src/middleware/stream-rate-limiter.middleware.ts both configure an express-rate-limit instance with a store and window, presumably repeating the same Redis/memory-store selection logic and key-generation boilerplate. Duplicated configuration means a fix to one (e.g. the trust-proxy IP-keying bug already tracked) has to be manually mirrored in the other.

Acceptance criteria

  • Extract a shared createRateLimiter(options) factory used by both middlewares
  • Migrate both files to use the shared factory
  • Confirm existing rate-limiter tests still pass unchanged

Files to touch

  • backend/src/middleware/rate-limiter.middleware.ts
  • backend/src/middleware/stream-rate-limiter.middleware.ts

Out of scope

  • Fixing the trust-proxy IP-keying issue itself (tracked separately)
  • Switching rate-limit backends

Activity

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

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Stellar WaveIssues in the Stellar wave programThird CampaignCampaign: Third CampaignbackendBackend related tasksrefactorRefactoring existing code

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions