The Problem
With express-rate-limit, tiered limits require:
- Creating 3 separate limiter instances
- Writing manual routing logic
- 25 lines of code minimum
The Solution
app.use(hitlimit({
tiers: {
free: { limit: 100, window: '1h' },
pro: { limit: 5000, window: '1h' },
enterprise: { limit: Infinity }
},
tier: (req) => req.user?.plan || 'free'
}))
8 lines. Done.
Benchmarks
I ran 1.5M iterations per scenario. Raw store operations to keep it fair:
| Library | ops/sec |
|---|---|
| hitlimit | 9.56M 🏆 |
| express-rate-limit | 6.32M |
| rate-limiter-flexible | 1.01M |
Benchmark script is in the repo if you want to verify.
Other features:
- Human-readable time windows (
'15m'instead of900000) - 7KB bundle (vs 45KB for rate-limiter-flexible)
- Memory, SQLite, and Redis stores
- Per-request error handling (fail-open vs fail-closed)
Links:
- GitHub: https://github.com/JointOps/hitlimit-monorepo
- npm:
npm install @joint-ops/hitlimit - Docs: https://hitlimit.jointops.dev
It's brand new, so feedback is super welcome. What features would make this useful for your projects?
Top comments (0)