Improved points and duration validation#354
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens the RateLimiter configuration contract by making points and duration explicitly required (types + docs) and enforcing runtime validation (notably: duration must be non-negative), with broad test updates to reflect the new requirements.
Changes:
- Make
pointsanddurationrequired in TypeScript types and README docs. - Add stricter runtime validation in
RateLimiterAbstractand add unit tests around validation behavior. - Update many tests/fixtures to pass
points/duration, and update CI matrix versions.
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
lib/RateLimiterAbstract.js |
Enforces required points/duration with validation logic. |
types.d.ts |
Makes points/duration required in IRateLimiterOptions. |
README.md |
Documents points/duration as required options. |
lib/RateLimiterValkeyGlide.js |
Updates JSDoc to reflect required points/duration. |
.github/workflows/test.yml |
Updates Node/Valkey matrix versions. |
test/RateLimiterAbstract.test.js |
Adds validation-focused unit tests; updates instantiation for required options. |
test/RLWrapperTimeouts.test.js |
Updates wrapper and stubbed limiters to pass required options. |
test/RateLimiterSQLite.test.js |
Adjusts concurrency assertion (now order-independent). |
test/RateLimiterRedis.redis.test.js |
Adds required options to constructors in tests. |
test/RateLimiterRedis.ioredis.test.js |
Adds required options to constructors in tests. |
test/RateLimiterValkeyGlide.test.js |
Adds required options to constructors in tests. |
test/RateLimiterValkey.iovalkey.test.js |
Adds required options to constructors in tests. |
test/RateLimiterPrisma/Postgres/RateLimiterPrismaPostgres.test.js |
Adds required duration to constructor usage. |
test/RateLimiterDrizzle/Postgres/RateLimiterDrizzlePostgres.test.js |
Adds required duration to constructor usage. |
test/RateLimiterDrizzle/Postgres/RateLimiterDrizzleNonAtomicPostgres.test.js |
Adds required duration to constructor usage. |
test/RateLimiterPostgres.test.js |
Adds required options to numerous constructor usages. |
test/RateLimiterMySQL.test.js |
Adds required options to constructor usages. |
test/RateLimiterMongo.test.js |
Adds required options to constructor usages. |
test/RateLimiterMemcache.test.js |
Adds required options to constructor usage. |
test/RateLimiterInsuredAbstract.test.js |
Updates stubs/constructors to satisfy new requirements. |
test/RateLimiterEtcd.test.js |
Adds required options to constructor usages (including error-path tests). |
test/RateLimiterEtcdNonAtomic.test.js |
Adds required options to constructor usages (including error-path tests). |
test/RateLimiterDynamo.test.js |
Adds required options and formatting cleanup. |
test/RateLimiterCluster.test.js |
Adds required options to cluster constructor usages. |
test/BurstyRateLimiter.test.js |
Adds required options to limiter constructors used in tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
pointsanddurationoptions are required numbers.duration can't be negative.