@reldens/server-utils 0.21.0 → 0.23.0

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.
@@ -35,13 +35,13 @@ class RateLimitConfigurer
35
35
  }
36
36
  let limiterParams = {
37
37
  windowMs: this.windowMs,
38
- max: this.maxRequests,
38
+ limit: this.maxRequests,
39
39
  standardHeaders: true,
40
40
  legacyHeaders: false,
41
41
  message: this.tooManyRequestsMessage
42
42
  };
43
43
  if(this.isDevelopmentMode){
44
- limiterParams.max = this.maxRequests * this.developmentMultiplier;
44
+ limiterParams.limit = this.maxRequests * this.developmentMultiplier;
45
45
  }
46
46
  if(this.applyKeyGenerator){
47
47
  limiterParams.keyGenerator = function(req){
@@ -55,12 +55,12 @@ class RateLimitConfigurer
55
55
  {
56
56
  let limiterParams = {
57
57
  windowMs: this.windowMs,
58
- max: this.maxRequests,
58
+ limit: this.maxRequests,
59
59
  standardHeaders: true,
60
60
  legacyHeaders: false
61
61
  };
62
62
  if(this.isDevelopmentMode){
63
- limiterParams.max = this.maxRequests * this.developmentMultiplier;
63
+ limiterParams.limit = this.maxRequests * this.developmentMultiplier;
64
64
  }
65
65
  if(this.applyKeyGenerator){
66
66
  limiterParams.keyGenerator = function(req){
@@ -79,6 +79,33 @@ class FileHandler
79
79
  return randomStr + ext;
80
80
  }
81
81
 
82
+ getFileStats(filePath)
83
+ {
84
+ if(!this.isValidPath(filePath)){
85
+ this.error = {message: 'Invalid file path.', filePath};
86
+ return false;
87
+ }
88
+ if(!this.exists(filePath)){
89
+ this.error = {message: 'File does not exist.', filePath};
90
+ return false;
91
+ }
92
+ try {
93
+ return fs.statSync(filePath);
94
+ } catch (error) {
95
+ this.error = {message: 'Failed to get file stats.', error, filePath};
96
+ return false;
97
+ }
98
+ }
99
+
100
+ getFileModificationTime(filePath)
101
+ {
102
+ let stats = this.getFileStats(filePath);
103
+ if(!stats){
104
+ return false;
105
+ }
106
+ return stats.mtime;
107
+ }
108
+
82
109
  remove(fullPath)
83
110
  {
84
111
  let deletePath = Array.isArray(fullPath) ? this.joinPaths(...fullPath) : fullPath;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reldens/server-utils",
3
3
  "scope": "@reldens",
4
- "version": "0.21.0",
4
+ "version": "0.23.0",
5
5
  "description": "Reldens - Server Utils",
6
6
  "author": "Damian A. Pastorini",
7
7
  "license": "MIT",
@@ -35,14 +35,14 @@
35
35
  "url": "https://github.com/damian-pastorini/reldens-server-utils/issues"
36
36
  },
37
37
  "dependencies": {
38
- "body-parser": "2.2.0",
39
- "compression": "1.8.0",
40
- "cors": "2.8.5",
41
- "express": "4.21.2",
42
- "express-rate-limit": "7.5.1",
43
- "express-session": "1.18.1",
44
- "helmet": "8.1.0",
45
- "multer": "2.0.1",
46
- "sanitize-html": "2.17.0"
38
+ "body-parser": "^2.2.0",
39
+ "compression": "^1.8.1",
40
+ "cors": "^2.8.5",
41
+ "express": "^4.21.2",
42
+ "express-rate-limit": "^8.0.1",
43
+ "express-session": "^1.18.2",
44
+ "helmet": "^8.1.0",
45
+ "multer": "^2.0.2",
46
+ "sanitize-html": "^2.17.0"
47
47
  }
48
48
  }