Skip to content

feat(web): add clearRateLimit helper and Vitest unit test suite - #111

Closed
Echolonius wants to merge 3 commits into
profullstack:masterfrom
Echolonius:feat/rate-limit-clear-helper
Closed

feat(web): add clearRateLimit helper and Vitest unit test suite#111
Echolonius wants to merge 3 commits into
profullstack:masterfrom
Echolonius:feat/rate-limit-clear-helper

Conversation

@Echolonius

Copy link
Copy Markdown
Contributor

🚀 Feature: Export clearRateLimit Helper & Add Vitest Unit Test Suite

💡 Overview & Problem Statement

Currently, apps/web/lib/rate-limit.ts implements an in-memory fixed-window rate limiter using internal buckets Map. However, there was no exported helper function to reset buckets (either by specific key or globally), making unit testing and admin rate limit resets difficult. Additionally, rate-limit.ts lacked a unit test file.

🛠️ Solution Implementation

  1. Reset Helper (apps/web/lib/rate-limit.ts):
    • Exported clearRateLimit(key?: string): void that clears a specific bucket key or resets all buckets when called without arguments.
  2. Vitest Unit Test Suite (apps/web/lib/rate-limit.test.ts):
    • Added unit test verifying initial requests calculate correct remaining count.
    • Added unit test verifying rate limit thresholds block excess calls (ok: false).
    • Added unit test verifying clearRateLimit(key) resets bucket limits cleanly.

✅ Verification

  • All 3 rate limit unit tests passing (100% clean).
  • All 93 Vitest web tests passing cleanly.
  • Signed with GPG/SSH key.

🤖 Agent Payout Metadata

  • Base USDC: 0xd194AB36E66BccDD80f19b56757CFe52EdEd49af
  • Solana USDC/SOL: 3wbinZDnWmDxHMLtACNrskwZvRwg4KYbBWw1wuviXXHT

…etch failures (fixes profullstack#93)

- Expose getCoinpayPaymentDetailed returning structured success/error status
- Ensure HTTP non-2xx status and payload parsing failures are logged with context instead of swallowed
- Add comprehensive Vitest unit test suite in apps/web/lib/coinpay.test.ts
…ixes profullstack#90)

- Add root app/api/route.ts returning standard JSON 404 error instead of falling back to HTML 404 page
- Add OPTIONS and HEAD verb handlers to app/api/[[...slug]]/route.ts and app/api/route.ts
- Add unit test suite in apps/web/lib/api-notFound.test.ts verifying status 404 and JSON body format
@ralyodio

ralyodio commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded by #109, now merged.

#109 replaced the in-memory limiter with a DB-backed one (new rate_limits table + migration 0016) so limits hold across instances, which conflicts with the clearRateLimit helper added here against the old Map-based implementation.

The /api route work in this branch shipped separately via #108. If a clearRateLimit equivalent is still useful for tests or admin resets against the new DB-backed store, a fresh PR on top of current master would be welcome. Thanks.

@ralyodio ralyodio closed this Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants