Compare commits

...

10 Commits

Author SHA1 Message Date
Salman Qureshi 7cfa9d2f01 Update README.md 2025-05-01 21:20:27 +05:30
Salman Qureshi c838164839 updated readme 2025-05-01 21:15:20 +05:30
Salman Qureshi fb784b6da8 updated readme 2025-05-01 21:14:29 +05:30
Salman Qureshi d6c5717d47 updated readme 2025-05-01 21:12:49 +05:30
Salman Qureshi 15e33f6d8e no-logo-naas 2025-05-01 21:09:55 +05:30
Salman Qureshi afe3e16bc1 Update README.md 2025-05-01 20:34:09 +05:30
Salman Qureshi 18a66f6068 added 1000+ better no reasons 2025-05-01 16:59:49 +05:30
Salman Qureshi 2387884993 docs: updated rate limit logic to allow 120 req/min per IP using CF-Connecting-IP behind Cloudflare, fallback compatable #8 2025-05-01 16:30:06 +05:30
Salman Qureshi 6f72cd77f8 feat(rate-limiting): trust CF-Connecting-IP behind Cloudflare and increase limit to 120 req/min/IP 2025-05-01 16:27:19 +05:30
Salman Qureshi 08759b2f3f removed limitting api calls 2025-04-30 21:02:14 +05:30
4 changed files with 1058 additions and 987 deletions
+14 -2
View File
@@ -1,7 +1,7 @@
# ❌ No-as-a-Service # ❌ No-as-a-Service
<p align="center"> <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> </p>
@@ -10,6 +10,18 @@ This tiny API returns random, generic, creative, and sometimes hilarious rejecti
Built for humans, excuses, and humor. 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 ## 🚀 API Usage
@@ -20,7 +32,7 @@ https://naas.isalman.dev/no
``` ```
**Method:** `GET` **Method:** `GET`
**Rate Limit:** `10 requests per minute per IP` **Rate Limit:** `120 requests per minute per IP`
### 🔄 Example Request ### 🔄 Example Request
```http ```http
Binary file not shown.

After

Width:  |  Height:  |  Size: 476 KiB

+7 -3
View File
@@ -3,16 +3,20 @@ const rateLimit = require('express-rate-limit');
const fs = require('fs'); const fs = require('fs');
const app = express(); const app = express();
app.set('trust proxy', true);
const PORT = process.env.PORT || 3000; const PORT = process.env.PORT || 3000;
// Load reasons from JSON // Load reasons from JSON
const reasons = JSON.parse(fs.readFileSync('./reasons.json', 'utf-8')); 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({ const limiter = rateLimit({
windowMs: 60 * 1000, // 1 minute windowMs: 60 * 1000, // 1 minute
max: 10, max: 120,
message: { error: "Too many requests, please try again later." } 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); app.use(limiter);
+1036 -981
View File
File diff suppressed because it is too large Load Diff