@bee.js/node 0.0.37 → 0.0.38
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/beeRequest.js +42 -42
- package/beehive.js +482 -482
- package/index.js +14 -14
- package/lib/DBA/beeDBA.js +119 -119
- package/lib/DEV/beeDEV.js +41 -41
- package/lib/JWT/beeJWT.js +72 -72
- package/lib/ORM/beeORM.js +319 -314
- package/lib/WEB/freeRoute.js +4 -4
- package/lib/WEB/route.js +27 -27
- package/lib/beeHive/create.js +51 -51
- package/lib/beeHive/headers.js +9 -9
- package/lib/beeHive/load.js +19 -19
- package/lib/beeHive/log.js +2 -2
- package/lib/beeHive/routes.js +34 -34
- package/lib/beeHive/start.js +29 -29
- package/package.json +40 -40
- package/security/index.js +8 -8
- package/services/CRON.js +8 -8
- package/services/EMAIL.js +2 -2
- package/services/HTTP.js +32 -32
- package/services/HTTPS.js +31 -31
- package/services/LOGS.js +7 -7
- package/services/SCRIPT.js +13 -13
- package/services/SHELL.js +2 -2
- package/services/index.js +9 -9
- package/tools/beeTools.js +18 -18
- package/tools/guid.js +14 -14
- package/tools/hash.js +12 -12
- package/tools/model.js +20 -20
- package/tools/slug.js +16 -16
- package/tools/string.js +55 -55
package/beeRequest.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
module.exports = function request(req, res, ...validations) {
|
|
2
|
-
|
|
3
|
-
let valid = true
|
|
4
|
-
let failConditions = []
|
|
5
|
-
let error = {}
|
|
6
|
-
|
|
7
|
-
req.onlyFields = {}
|
|
8
|
-
|
|
9
|
-
validations
|
|
10
|
-
.map(validation => {
|
|
11
|
-
// filter fields
|
|
12
|
-
if(validation.onlyFields && validation.onlyFields !== "*")
|
|
13
|
-
req.onlyFields[validation.model] = validation.onlyFields.split(",").map(field => field.trim()) //TODO otimizar colocando na memoria
|
|
14
|
-
|
|
15
|
-
// fail conditions
|
|
16
|
-
for([condition, fn] of Object.entries(validation.failConditions || []) ) {
|
|
17
|
-
|
|
18
|
-
let fail = fn(req)
|
|
19
|
-
|
|
20
|
-
if(!fail || fail.error === true) {
|
|
21
|
-
failConditions.push(condition)
|
|
22
|
-
error.message = fail && fail.message ? fail.message : ''
|
|
23
|
-
valid = false
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
return new Promise(function(resolve, reject) {
|
|
29
|
-
valid === true
|
|
30
|
-
? resolve(req)
|
|
31
|
-
: reject({
|
|
32
|
-
requestError: function(_error = error, errorCode = 400) {
|
|
33
|
-
try {
|
|
34
|
-
res
|
|
35
|
-
.status(errorCode)
|
|
36
|
-
.send({error: {message: _error.message || 'There was an error in the request'}, failConditions })
|
|
37
|
-
} catch {
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
})
|
|
1
|
+
module.exports = function request(req, res, ...validations) {
|
|
2
|
+
|
|
3
|
+
let valid = true
|
|
4
|
+
let failConditions = []
|
|
5
|
+
let error = {}
|
|
6
|
+
|
|
7
|
+
req.onlyFields = {}
|
|
8
|
+
|
|
9
|
+
validations
|
|
10
|
+
.map(validation => {
|
|
11
|
+
// filter fields
|
|
12
|
+
if(validation.onlyFields && validation.onlyFields !== "*")
|
|
13
|
+
req.onlyFields[validation.model] = validation.onlyFields.split(",").map(field => field.trim()) //TODO otimizar colocando na memoria
|
|
14
|
+
|
|
15
|
+
// fail conditions
|
|
16
|
+
for([condition, fn] of Object.entries(validation.failConditions || []) ) {
|
|
17
|
+
|
|
18
|
+
let fail = fn(req)
|
|
19
|
+
|
|
20
|
+
if(!fail || fail.error === true) {
|
|
21
|
+
failConditions.push(condition)
|
|
22
|
+
error.message = fail && fail.message ? fail.message : ''
|
|
23
|
+
valid = false
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
return new Promise(function(resolve, reject) {
|
|
29
|
+
valid === true
|
|
30
|
+
? resolve(req)
|
|
31
|
+
: reject({
|
|
32
|
+
requestError: function(_error = error, errorCode = 400) {
|
|
33
|
+
try {
|
|
34
|
+
res
|
|
35
|
+
.status(errorCode)
|
|
36
|
+
.send({error: {message: _error.message || 'There was an error in the request'}, failConditions })
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
})
|
|
43
43
|
}
|