Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7cfa9d2f01 | |||
| c838164839 | |||
| fb784b6da8 | |||
| d6c5717d47 | |||
| 15e33f6d8e | |||
| afe3e16bc1 | |||
| 18a66f6068 | |||
| 2387884993 | |||
| 6f72cd77f8 | |||
| 08759b2f3f |
@@ -1,7 +1,7 @@
|
||||
# ❌ No-as-a-Service
|
||||
|
||||
<p align="center">
|
||||
<img src="https://raw.githubusercontent.com/hotheadhacker/no-as-a-service/main/assets/imgs/image.png" width="800" alt="No-as-a-Service Banner"/>
|
||||
<img src="https://raw.githubusercontent.com/hotheadhacker/no-as-a-service/main/assets/imgs/naas-with-no-logo-bunny.png" width="800" alt="No-as-a-Service Banner" width="70%"/>
|
||||
</p>
|
||||
|
||||
|
||||
@@ -10,6 +10,18 @@ This tiny API returns random, generic, creative, and sometimes hilarious rejecti
|
||||
|
||||
Built for humans, excuses, and humor.
|
||||
|
||||
<!-- GitAds Sponsorship Badge -->
|
||||
<p align="center">
|
||||
<a href="https://docs.gitads.dev/">
|
||||
<img src="https://gitads.dev/assets/images/sponsor/camos/camo-3.png" alt="Sponsored by GitAds" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
This project is <strong>sponsored by <a href="https://docs.gitads.dev/docs/getting-started/publishers">GitAds</a></strong>.<br>
|
||||
You can get your GitHub repository sponsored too — <a href="https://docs.gitads.dev/docs/getting-started/publishers">create your account now</a>.
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
## 🚀 API Usage
|
||||
@@ -20,7 +32,7 @@ https://naas.isalman.dev/no
|
||||
```
|
||||
|
||||
**Method:** `GET`
|
||||
**Rate Limit:** `10 requests per minute per IP`
|
||||
**Rate Limit:** `120 requests per minute per IP`
|
||||
|
||||
### 🔄 Example Request
|
||||
```http
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 476 KiB |
@@ -3,16 +3,20 @@ const rateLimit = require('express-rate-limit');
|
||||
const fs = require('fs');
|
||||
|
||||
const app = express();
|
||||
app.set('trust proxy', true);
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
// Load reasons from JSON
|
||||
const reasons = JSON.parse(fs.readFileSync('./reasons.json', 'utf-8'));
|
||||
|
||||
// Rate limiter: 10 requests per minute per IP
|
||||
// Rate limiter: 120 requests per minute per IP
|
||||
const limiter = rateLimit({
|
||||
windowMs: 60 * 1000, // 1 minute
|
||||
max: 10,
|
||||
message: { error: "Too many requests, please try again later." }
|
||||
max: 120,
|
||||
keyGenerator: (req, res) => {
|
||||
return req.headers['cf-connecting-ip'] || req.ip; // Fallback if header missing (or for non-CF)
|
||||
},
|
||||
message: { error: "Too many requests, please try again later. (120 reqs/min/IP)" }
|
||||
});
|
||||
|
||||
app.use(limiter);
|
||||
|
||||
+1036
-981
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user