Skip to content

Commit ef05c64

Browse files
committed
Documentation
1 parent 4aff80b commit ef05c64

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

Diff for: README.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
# Rate Limiter Middleware using Neon and Rust
3+
4+
This project demonstrates an IP-based rate-limiting middleware implemented using Rust and integrated with an Express.js application through the Neon framework.
5+
6+
## Features
7+
8+
- High-performance IP-based rate limiting using Rust.
9+
- Customizable rate limiting configurations (maximum requests, time window, burst allowance).
10+
- Middleware seamlessly integrates with any Express.js application.
11+
- Real-time stress testing using `autocannon`.
12+
13+
## Project Structure
14+
15+
```
16+
project/
17+
├── index.js # Express.js server with Rust-based rate limiter
18+
├── native/
19+
│ ├── Cargo.toml # Rust dependencies and metadata
20+
│ └── src/
21+
│ └── lib.rs # Rust implementation of the rate limiter
22+
├── test-rate-limiter.js # Test script using autocannon
23+
├── package.json # Node.js dependencies and scripts
24+
└── README.md # Project documentation
25+
```
26+
27+
## Prerequisites
28+
29+
- **Node.js**: Install Node.js from [nodejs.org](https://nodejs.org).
30+
- **Rust**: Install Rust and Cargo from [rust-lang.org](https://www.rust-lang.org).
31+
- **Neon CLI**: Install the Neon CLI globally using npm:
32+
```bash
33+
npm install -g neon-cli
34+
```
35+
36+
## Configuration
37+
38+
You can customize the rate-limiting parameters in the Express server (`index.js`):
39+
40+
```javascript
41+
const rateLimiter = createRateLimiter(maxRequests, windowSeconds, burstAllowance);
42+
```
43+
44+
- **maxRequests**: Maximum number of requests allowed in the time window.
45+
- **windowSeconds**: Time window in seconds for rate limiting.
46+
- **burstAllowance**: Number of extra requests allowed temporarily as a burst.

0 commit comments

Comments
 (0)