not-node 4.0.7 → 4.0.11
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/.eslintrc.json +2 -1
- package/bin/not-builder.js +6 -2
- package/package.json +11 -11
- package/src/form/index.js +1 -1
- package/src/init/rateLimiter.js +17 -7
- package/src/manifest/route.js +12 -8
package/.eslintrc.json
CHANGED
package/bin/not-builder.js
CHANGED
|
@@ -16,7 +16,7 @@ var argv = require('yargs').argv,
|
|
|
16
16
|
path = require('path'),
|
|
17
17
|
child_process = require('child_process'),
|
|
18
18
|
deepMerge = require('deepmerge'),
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
lib = require('../src/lib.js');
|
|
21
21
|
|
|
22
22
|
const TEMPLATES_EXT = '.html';
|
|
@@ -31,6 +31,7 @@ let opts = {
|
|
|
31
31
|
'to': argv.to || false,
|
|
32
32
|
'config': argv.config || './project.manifest.json',
|
|
33
33
|
'rollup': argv.rollup || path.join(process.cwd(),'./node_modules/.bin/rollup'),
|
|
34
|
+
'role': argv.role || null
|
|
34
35
|
},
|
|
35
36
|
configName = path.join(process.cwd(), opts.config),
|
|
36
37
|
config = {};
|
|
@@ -493,7 +494,10 @@ async function build_Server(pathToRoot, roles, targetName, targetManifest){
|
|
|
493
494
|
console.log('List:', list);
|
|
494
495
|
////forming index.js and rollup.js
|
|
495
496
|
for(let i = 0; i < roles.length; i++){
|
|
496
|
-
|
|
497
|
+
const role = roles[i];
|
|
498
|
+
if((opts.role !== null) && opts.role !== role){
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
497
501
|
try{
|
|
498
502
|
let indexFile = path.join(pathToRoot, targetManifest.src, 'index.' + role + '.js');
|
|
499
503
|
let rollupFile = path.join(pathToRoot, targetManifest.root, 'rollup.' + role + '.js');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "not-node",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.11",
|
|
4
4
|
"description": "node complimentary part for client side notFramework.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -53,36 +53,36 @@
|
|
|
53
53
|
"mongoose": "*",
|
|
54
54
|
"mongoose-validator": "*",
|
|
55
55
|
"nconf": "*",
|
|
56
|
-
"not-config": "^0.1.
|
|
57
|
-
"not-error": "^0.2.
|
|
56
|
+
"not-config": "^0.1.4",
|
|
57
|
+
"not-error": "^0.2.1",
|
|
58
58
|
"not-filter": "*",
|
|
59
59
|
"not-inform": "^0.0.27",
|
|
60
60
|
"not-locale": "*",
|
|
61
61
|
"not-log": "^0.0.20",
|
|
62
62
|
"not-monitor": "^0.0.13",
|
|
63
63
|
"not-path": "*",
|
|
64
|
-
"rate-limiter-flexible": "^2.3.
|
|
65
|
-
"redis": "^
|
|
64
|
+
"rate-limiter-flexible": "^2.3.6",
|
|
65
|
+
"redis": "^4.0.0",
|
|
66
66
|
"rmdir": "^1.2.0",
|
|
67
67
|
"serve-static": "*",
|
|
68
68
|
"simple-git": "*",
|
|
69
69
|
"yargs": "*"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@babel/eslint-parser": "^7.
|
|
72
|
+
"@babel/eslint-parser": "^7.16.3",
|
|
73
73
|
"babel-eslint": "^10.1.0",
|
|
74
74
|
"chai": "*",
|
|
75
75
|
"chai-as-promised": "*",
|
|
76
|
-
"eslint": "^
|
|
76
|
+
"eslint": "^8.3.0",
|
|
77
77
|
"eslint-plugin-node": "^11.1.0",
|
|
78
|
-
"eslint-plugin-promise": "^5.
|
|
79
|
-
"eslint-plugin-sonarjs": "^0.
|
|
78
|
+
"eslint-plugin-promise": "^5.2.0",
|
|
79
|
+
"eslint-plugin-sonarjs": "^0.11.0",
|
|
80
80
|
"ink-docstrap": "^1.3.2",
|
|
81
|
-
"ioredis": "^4.28.
|
|
81
|
+
"ioredis": "^4.28.2",
|
|
82
82
|
"jsdoc": "^3.6.7",
|
|
83
83
|
"mocha": "*",
|
|
84
84
|
"mocha-suppress-logs": "^0.3.1",
|
|
85
|
-
"mongodb-memory-server": "^
|
|
85
|
+
"mongodb-memory-server": "^8.0.4",
|
|
86
86
|
"npm-run-all": "^4.1.5",
|
|
87
87
|
"nyc": "^15.1.0",
|
|
88
88
|
"retire": "^3.0.3"
|
package/src/form/index.js
CHANGED
|
@@ -22,7 +22,7 @@ module.exports = class Form {
|
|
|
22
22
|
this.FORM_NAME = FORM_NAME;
|
|
23
23
|
this.FIELDS = FIELDS;
|
|
24
24
|
this.SCHEMA = byFieldsValidators(initFields(FIELDS, 'model'));
|
|
25
|
-
if (mongoose.modelNames().indexOf(
|
|
25
|
+
if (mongoose.modelNames().indexOf(FORM_NAME)===-1){
|
|
26
26
|
this.MODEL = mongoose.model(FORM_NAME, Schema(this.SCHEMA));
|
|
27
27
|
}else{
|
|
28
28
|
this.MODEL = mongoose.connection.model(FORM_NAME);
|
package/src/init/rateLimiter.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
const emit = require('./additional').run;
|
|
2
2
|
const log = require('not-log')(module, 'RateLimiter');
|
|
3
3
|
|
|
4
|
+
const DEFAULT_OPTIONS = {
|
|
5
|
+
keyPrefix: 'rateLimiterMiddleware',
|
|
6
|
+
points: 20,
|
|
7
|
+
duration: 1
|
|
8
|
+
};
|
|
9
|
+
|
|
4
10
|
module.exports = class InitRateLimiter{
|
|
5
11
|
|
|
6
12
|
static createMiddleware({rateLimiter}){
|
|
7
13
|
return (req, res, next) => {
|
|
8
14
|
rateLimiter.consume(req.ip)
|
|
9
|
-
.then(() =>
|
|
10
|
-
next();
|
|
11
|
-
})
|
|
15
|
+
.then(() => next())
|
|
12
16
|
.catch(() => {
|
|
13
17
|
log.error('Too many requests by ' + req.ip);
|
|
14
18
|
res.status(429).send('Too Many Requests');
|
|
@@ -24,13 +28,19 @@ module.exports = class InitRateLimiter{
|
|
|
24
28
|
await emit('rateLimiter.post', { config, master});
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
|
|
32
|
+
getOptions({config}){
|
|
33
|
+
return {
|
|
34
|
+
...DEFAULT_OPTIONS,
|
|
35
|
+
...config.get('modules.rateLimiter', {})
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static createRateLimiter({master, config}){
|
|
28
40
|
const {RateLimiterRedis} = require('rate-limiter-flexible');
|
|
29
41
|
return new RateLimiterRedis({
|
|
30
42
|
storeClient: master.getEnv('db.redis'),
|
|
31
|
-
|
|
32
|
-
points: 100, // 10 requests
|
|
33
|
-
duration: 1, // per 1 second by IP
|
|
43
|
+
...this.getOptions({master, config})
|
|
34
44
|
});
|
|
35
45
|
}
|
|
36
46
|
};
|
package/src/manifest/route.js
CHANGED
|
@@ -162,14 +162,18 @@ class notRoute{
|
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
async executeRoute(modRoute, actionName, {req, res, next}){
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
165
|
+
try{
|
|
166
|
+
//waiting preparation
|
|
167
|
+
let prepared = await this.executeFunction(modRoute, CONST_BEFORE_ACTION, [req, res, next]);
|
|
168
|
+
//waiting results
|
|
169
|
+
let result = await this.executeFunction(modRoute, actionName, [req, res, next, prepared]);
|
|
170
|
+
//filter result IF actionData.return specified
|
|
171
|
+
this.filterResultByReturnRule(req, result);
|
|
172
|
+
//run after with results, continue without waiting when it finished
|
|
173
|
+
return this.executeFunction(modRoute, CONST_AFTER_ACTION, [req, res, next, result]);
|
|
174
|
+
}catch(e){
|
|
175
|
+
next(e);
|
|
176
|
+
}
|
|
173
177
|
}
|
|
174
178
|
|
|
175
179
|
async executeFunction(obj, name, params) {
|