https://github.com/kartikmehta8/rust-rate-limiter
A high-performance IP-based rate-limiting middleware for Express.js, powered by Rust and Neon.
https://github.com/kartikmehta8/rust-rate-limiter
express ip-rate-limit neon rust
Last synced: 2 months ago
JSON representation
A high-performance IP-based rate-limiting middleware for Express.js, powered by Rust and Neon.
- Host: GitHub
- URL: https://github.com/kartikmehta8/rust-rate-limiter
- Owner: kartikmehta8
- Created: 2024-12-19T14:08:54.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-12-19T14:09:27.000Z (5 months ago)
- Last Synced: 2025-03-09T21:43:12.610Z (2 months ago)
- Topics: express, ip-rate-limit, neon, rust
- Language: Rust
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rate Limiter Middleware using Neon and Rust
This project demonstrates an IP-based rate-limiting middleware implemented using Rust and integrated with an Express.js application through the Neon framework.
## Features
- High-performance IP-based rate limiting using Rust.
- Customizable rate limiting configurations (maximum requests, time window, burst allowance).
- Middleware seamlessly integrates with any Express.js application.
- Real-time stress testing using `autocannon`.## Project Structure
```
project/
├── index.js # Express.js server with Rust-based rate limiter
├── native/
│ ├── Cargo.toml # Rust dependencies and metadata
│ └── src/
│ └── lib.rs # Rust implementation of the rate limiter
├── test-rate-limiter.js # Test script using autocannon
├── package.json # Node.js dependencies and scripts
└── README.md # Project documentation
```## Prerequisites
- **Node.js**: Install Node.js from [nodejs.org](https://nodejs.org).
- **Rust**: Install Rust and Cargo from [rust-lang.org](https://www.rust-lang.org).
- **Neon CLI**: Install the Neon CLI globally using npm:
```bash
npm install -g neon-cli
```## Configuration
You can customize the rate-limiting parameters in the Express server (`index.js`):
```javascript
const rateLimiter = createRateLimiter(maxRequests, windowSeconds, burstAllowance);
```- **maxRequests**: Maximum number of requests allowed in the time window.
- **windowSeconds**: Time window in seconds for rate limiting.
- **burstAllowance**: Number of extra requests allowed temporarily as a burst.