A multi-tenant rate limiting service built with Elysia and Bun, implementing a leaky bucket algorithm with Redis persistence.
- Multi-tenancy: Each user gets their own leaky bucket
- Bearer Token Authentication: Simple token validation
- Token Management:
- Decreases by 1 on every request
- Permanently removed on failed requests (status !== 200)
- Replenished 1 per hour, capped at 10 tokens max
- Framework: Elysia with Bun runtime
- Database: Redis for bucket state persistence
- Queue: BullMQ for scheduled token refills
- Rate Limiting: Leaky bucket algorithm per user
docker compose up -d
docker exec api shOpen http://localhost:3000/ to see the API.
- Each request consumes 1 token
- Failed requests (non-200 status) permanently remove tokens
- Tokens are automatically replenished at 1 per hour
- Maximum bucket capacity: 10 tokens