Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2a72121
feat: add RateLimiter class for managing API request limits
max-programming Oct 25, 2025
5706bd1
feat: add RATE_LIMIT_EXCEEDED error type and message to ApiKeyError
max-programming Oct 25, 2025
132196b
feat: add createRateLimiter method to ApiKeyManager for rate limiting…
max-programming Oct 25, 2025
1f153b6
test: add tests for RateLimiter functionality
max-programming Oct 25, 2025
e666472
docs: update README to include rate limiting feature with usage examples
max-programming Oct 25, 2025
6e1b3f6
docs: update feature suggestions to mark rate limiting as done and r…
max-programming Oct 25, 2025
a0ba1e7
Merge branch 'izadoesdev:main' into feat/rate-limit
max-programming Oct 25, 2025
893e074
fix: atomic increment and other minor issues suggested by coderabbit
max-programming Oct 25, 2025
b54c44d
Merge branch 'feat/rate-limit' of https://github.com/max-programming/…
max-programming Oct 25, 2025
ac80d6a
feat: integrate rate limiting by default in the manager (opt-in)
max-programming Oct 25, 2025
c49a92c
fix: bug fixes avoiding ttl being reset on each increment
max-programming Oct 25, 2025
d1753b7
Merge remote-tracking branch 'upstream/main' into feat/rate-limit
max-programming Oct 25, 2025
7111b18
chore: minor nitpick changes
max-programming Oct 25, 2025
0849e04
Merge branch 'main' into feat/rate-limit
max-programming Oct 26, 2025
de432b4
fix: cache the apikey record before checking rate limit
max-programming Oct 26, 2025
aca7506
Merge remote-tracking branch 'upstream/main' into feat/rate-limit
max-programming Oct 26, 2025
be57be9
fix: use real redis instance in cache tests
max-programming Oct 26, 2025
b718ef5
Merge remote-tracking branch 'upstream/main' into feat/rate-limit
max-programming Oct 26, 2025
8106af5
chore: properly use test hook functions
max-programming Oct 26, 2025
b60827a
Merge remote-tracking branch 'upstream/main' into feat/rate-limit
max-programming Oct 27, 2025
ef2fcaf
test: create a separate suit for rate limiting test cases and make us…
max-programming Oct 27, 2025
d06da27
fix: cache selective items from record when rate limiting is enabled
max-programming Oct 27, 2025
bfab6bc
chore: use helper function in error
max-programming Oct 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions FEATURE_SUGGESTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@

## Recommended Additions

### 1. Rate Limiting Helper
### 1. Key Rotation
```typescript
interface RateLimitConfig {
maxRequests: number
windowMs: number
}

// Usage:
const rateLimiter = keys.createRateLimiter({
maxRequests: 100,
windowMs: 60000, // 1 minute
// Rotate a key (create new, mark old as rotating)
const { newKey, oldRecord } = await keys.rotate(oldKeyId, {
gracePeriodMs: 86400000, // 24 hours
})

await rateLimiter.check(apiKeyRecord)
```

### 2. Usage Analytics
Expand All @@ -31,7 +23,22 @@ await keys.trackUsage(keyId, {
const stats = await keys.getUsageStats(keyId)
```

### 2. IP Whitelisting
### 3. Webhook Events
```typescript
keys.on('key.created', async (event) => {
await sendWebhook(event.ownerId, 'key_created', event.data)
})

keys.on('key.used', async (event) => {
// Log to analytics
})

keys.on('key.expired', async (event) => {
// Notify owner
})
```

### 4. IP Whitelisting
```typescript
await keys.create({
ownerId: 'user_123',
Expand All @@ -41,7 +48,7 @@ await keys.create({
await keys.verify(key, { ipAddress: req.ip })
```

### 3. Request Signing
### 5. Request Signing
```typescript
// HMAC-based request signing
const signature = keys.sign(request, apiKey)
Expand All @@ -50,7 +57,7 @@ const signature = keys.sign(request, apiKey)
const isValid = await keys.verifySignature(request, signature, keyId)
```

### 4. Bulk Operations
### 6. Bulk Operations
```typescript
// Bulk create
const results = await keys.createBulk([
Expand All @@ -62,7 +69,7 @@ const results = await keys.createBulk([
await keys.revokeBulk(['key_1', 'key_2', 'key_3'])
```

### 5. Key Templates
### 7. Key Templates
```typescript
// Define reusable templates
const template = keys.defineTemplate('readonly', {
Expand Down Expand Up @@ -96,6 +103,7 @@ const { key } = await keys.createFromTemplate(template, {
- Key tags/labels
- Audit logging (opt-in)
- Key rotation
- Rate limiting (opt-in)

## Implementation Notes

Expand Down
Loading
Loading