fix: respect STREAM_CREATE_RATE_LIMIT in streamCreationRateLimiter#603
Open
wheval wants to merge 1 commit into
Open
fix: respect STREAM_CREATE_RATE_LIMIT in streamCreationRateLimiter#603wheval wants to merge 1 commit into
wheval wants to merge 1 commit into
Conversation
Omit hardcoded max from the exported limiter so operators can tune per-wallet stream creation limits via env var. Document the setting and add behavioral tests for the override. Closes LabsCrypt#549
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Summary
Fixes the pre-configured
streamCreationRateLimitersoSTREAM_CREATE_RATE_LIMITcontrols the per-wallet limit onPOST /v1/streams, and documents the env var in.env.example.🎯 Purpose / Motivation
streamCreationRateLimiterwas created withmax: 10hardcoded, which bypassed the factory’sSTREAM_CREATE_RATE_LIMITfallback. Operators could set the env var in production but the limit stayed at 10, and the JSDoc was misleading.🛠️ Changes Made
maxfromstreamCreationRateLimitersocreateStreamRateLimiterreadsSTREAM_CREATE_RATE_LIMIT(default 10).STREAM_CREATE_RATE_LIMITinbackend/.env.example.stream-rate-limiter.test.tswith behavioral tests for env override, including the exported limiter via dynamic import.🧪 How to Test
backend/, runnpm test -- stream-rate-limiter.test.ts— all tests should pass.STREAM_CREATE_RATE_LIMIT=3, start the backend, and send more than 3 authenticatedPOST /v1/streamsrequests from the same wallet within one minute — the 4th should return429.STREAM_CREATE_RATE_LIMIT=10) and confirm the default limit is 10.📸 Screenshots (if applicable)
N/A — backend-only change.
🔗 Related Issues
Closes #549
✅ Checklist