[PR #7313] [MERGED] chore: improve rate limiting type definitions #32821

Closed
opened 2026-04-17 23:32:44 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7313
Author: @himself65
Created: 1/13/2026
Status: Merged
Merged: 1/13/2026
Merged by: @himself65

Base: canaryHead: himself65/2026/01/12/improve


📝 Commits (2)

  • 28d3e82 chore: improve rate limiting type definitions
  • 69039b9 Merge branch 'canary' into himself65/2026/01/12/improve

📊 Changes

4 files changed (+72 additions, -64 deletions)

View changed files

📝 packages/better-auth/src/api/rate-limiter/index.ts (+40 -31)
📝 packages/core/src/types/context.ts (+4 -1)
📝 packages/core/src/types/index.ts (+2 -0)
📝 packages/core/src/types/init-options.ts (+26 -32)

📄 Description

Summary by cubic

Standardized rate limiting types and storage to make configuration safer and more flexible. Adds explicit storage and rule types, updates customRules to receive the current rule, and normalizes storage get to return null on misses.

  • Refactors
    • Introduced and exported BetterAuthRateLimitStorage and BetterAuthRateLimitRule.
    • AuthContext.rateLimit now flattens window, max, and storage; duplicates are omitted from BetterAuthRateLimitOptions.
    • customRules can be a function (request, currentRule) returning false or a rule; async supported.
    • Unified memory/secondary storage behavior: get returns null on miss/expiry; TTL derives from window.
    • Renamed createDBStorage to createDatabaseStorageWrapper; getRateLimitStorage now returns BetterAuthRateLimitStorage.

Written for commit 69039b94e3. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7313 **Author:** [@himself65](https://github.com/himself65) **Created:** 1/13/2026 **Status:** ✅ Merged **Merged:** 1/13/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `himself65/2026/01/12/improve` --- ### 📝 Commits (2) - [`28d3e82`](https://github.com/better-auth/better-auth/commit/28d3e82ef21afa5464722d12dfb3362b85ca843a) chore: improve rate limiting type definitions - [`69039b9`](https://github.com/better-auth/better-auth/commit/69039b94e38eff2c8831cd4cfe4f98c458c77154) Merge branch 'canary' into himself65/2026/01/12/improve ### 📊 Changes **4 files changed** (+72 additions, -64 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/rate-limiter/index.ts` (+40 -31) 📝 `packages/core/src/types/context.ts` (+4 -1) 📝 `packages/core/src/types/index.ts` (+2 -0) 📝 `packages/core/src/types/init-options.ts` (+26 -32) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Standardized rate limiting types and storage to make configuration safer and more flexible. Adds explicit storage and rule types, updates customRules to receive the current rule, and normalizes storage get to return null on misses. - **Refactors** - Introduced and exported BetterAuthRateLimitStorage and BetterAuthRateLimitRule. - AuthContext.rateLimit now flattens window, max, and storage; duplicates are omitted from BetterAuthRateLimitOptions. - customRules can be a function (request, currentRule) returning false or a rule; async supported. - Unified memory/secondary storage behavior: get returns null on miss/expiry; TTL derives from window. - Renamed createDBStorage to createDatabaseStorageWrapper; getRateLimitStorage now returns BetterAuthRateLimitStorage. <sup>Written for commit 69039b94e38eff2c8831cd4cfe4f98c458c77154. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 23:32:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#32821