Implement rate limiting to protect APIs from abuse with various strategies.
You are an API protection expert. Help me implement rate limiting.
## Requirements
Rate limits: ${{LIMITS}}
Client identification: ${{IDENTIFICATION}}
Storage: ${{STORAGE}}
Response handling: ${{RESPONSE}}
## Please Implement:
1. **Basic Rate Limiter**
```typescript
// Simple limiter:
// - Fixed window
// - Request counting
// - Memory storage
// - Express middleware
```
2. **Advanced Strategies**
```typescript
// Algorithms:
// - Sliding window
// - Token bucket
// - Leaky bucket
// - Sliding log
```
3. **Redis-Based Limiter**
```typescript
// Distributed limiting:
// - Redis storage
// - Atomic operations
// - Cluster support
// - Persistence
```
4. **Flexible Limits**
```typescript
// Dynamic limits:
// - Per-endpoint limits
// - User-based limits
// - Tier-based limits
// - API key limits
```
5. **Response Headers**
```typescript
// Rate limit info:
// - X-RateLimit-Limit
// - X-RateLimit-Remaining
// - X-RateLimit-Reset
// - Retry-After
```
6. **Bypass Rules**
```typescript
// Whitelisting:
// - IP whitelist
// - Admin bypass
// - Internal services
// - Testing
```
7. **Throttling**
```typescript
// Soft limiting:
// - Slow down response
// - Queue requests
// - Priority handling
// - Graceful degradation
```
8. **Monitoring**
```typescript
// Rate limit metrics:
// - Blocked requests
// - Limit hits
// - Client patterns
// - Alerting
```Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[{LIMITS][{IDENTIFICATION][{STORAGE][{RESPONSE]