@igea/oac_frontend 1.0.29 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/controllers/captcha.js +10 -1
- package/src/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@igea/oac_frontend",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.31",
|
|
4
4
|
"description": "Frontend service for the OAC project",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"axios": "1.10.0",
|
|
28
28
|
"cookie-parser": "1.4.7",
|
|
29
29
|
"express": "5.1.0",
|
|
30
|
+
"express-rate-limit": "8.1.0",
|
|
30
31
|
"get-port": "7.1.0",
|
|
31
32
|
"i18n": "0.15.1",
|
|
32
33
|
"twig": "1.17.1"
|
|
@@ -2,11 +2,20 @@ const express = require('express');
|
|
|
2
2
|
const router = express.Router();
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
|
+
const rateLimit = require('express-rate-limit');
|
|
5
6
|
|
|
6
7
|
// folder where your images are stored
|
|
7
8
|
const IMAGES_DIR = path.join(__dirname, '..', 'public', 'images', 'captcha');
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
const imageLimiter = rateLimit({
|
|
11
|
+
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
12
|
+
max: 100, // limit each IP to 100 requests per windowMs
|
|
13
|
+
message: 'Too many requests from this IP, please try again later.',
|
|
14
|
+
standardHeaders: true,
|
|
15
|
+
legacyHeaders: false,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
router.get('/random-image', imageLimiter, (req, res) => {
|
|
10
19
|
fs.readdir(IMAGES_DIR, (err, files) => {
|
|
11
20
|
if (err) {
|
|
12
21
|
console.error(err);
|
package/src/index.js
CHANGED