Skip to content

Conversation

@feyishola
Copy link
Contributor

Overview
Implements custom rate limiting middleware for OnChain Sage to prevent abuse on high-impact routes.
Changes

Added IP/wallet-based rate limiting via @nestjs/throttler to guard POST /signal, /vote, and /webhook endpoints
Created database entity and migration for rate_limit_violations table
Implemented Redis-backed throttler for distributed scaling
Added comprehensive unit and integration tests (100% coverage)

Technical Details

Rate limits default to 10 requests/60s, configurable via environment variables
Prioritizes wallet address over IP when available
Logs violation details including IP, wallet, timestamp, endpoint, and violated rule
Automatically returns 429 responses when limits exceeded

Testing

Unit tests verify middleware logic and repository interactions
E2E tests confirm rate limiting works across all protected routes
Tested with different rate limit configurations and client identifiers

Closes #183

@PeterOche PeterOche merged commit e3fdea0 into degenspot:main Apr 30, 2025
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.

Implement Abuse Prevention Middleware for Sensitive Routes

2 participants