not-node 6.2.20 → 6.2.21
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
CHANGED
package/src/manifest/route.js
CHANGED
|
@@ -191,15 +191,17 @@ class notRoute {
|
|
|
191
191
|
prepared,
|
|
192
192
|
]);
|
|
193
193
|
//filter result IF actionData.return specified
|
|
194
|
-
if (typeof result
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
194
|
+
if (typeof result !== "undefined" && result) {
|
|
195
|
+
if (typeof result.toObject === "function") {
|
|
196
|
+
result = result.toObject();
|
|
197
|
+
}
|
|
198
|
+
if (Array.isArray(result)) {
|
|
199
|
+
result = result.map((itm) =>
|
|
200
|
+
itm.toObject ? itm.toObject() : itm
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
notManifestRouteResultFilter.filter(req.notRouteData, result);
|
|
201
204
|
}
|
|
202
|
-
notManifestRouteResultFilter.filter(req.notRouteData, result);
|
|
203
205
|
//run after with results, continue without waiting when it finished
|
|
204
206
|
return this.executeFunction(modRoute, CONST_AFTER_ACTION, [
|
|
205
207
|
req,
|
|
@@ -4,44 +4,42 @@ const { MODULE_NAME } = require("../const");
|
|
|
4
4
|
const Form = require("not-node").Form;
|
|
5
5
|
//form
|
|
6
6
|
const FIELDS = [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<% } %>
|
|
12
|
-
];
|
|
7
|
+
["activeUser", "not-node//requiredObject"],
|
|
8
|
+
["data", `${MODULE_NAME}//_<%- ModelName %>_data`],
|
|
9
|
+
["ip", "not-node//ip"],
|
|
10
|
+
];
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
const FORM_NAME = `${MODULE_NAME}:<%- ModelName %>CreateForm`;
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
**/
|
|
17
|
+
module.exports = class <%- ModelName %>CreateForm extends Form {
|
|
18
|
+
constructor({ app }) {
|
|
19
|
+
super({ FIELDS, FORM_NAME, app });
|
|
20
|
+
}
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Extracts data
|
|
24
|
+
* @param {ExpressRequest} req expressjs request object
|
|
25
|
+
* @return {Object} forma data
|
|
26
|
+
**/
|
|
27
|
+
extract(req) {
|
|
28
|
+
const ip = getIP(req);
|
|
29
|
+
const instructions = {
|
|
30
|
+
<% if (fields && Array.isArray(fields)) { %>
|
|
31
|
+
<% for(let field of fields){ %>
|
|
32
|
+
<%- field+': fromBody" ,' -%>
|
|
33
|
+
<% } %>
|
|
34
|
+
<% } %>
|
|
35
|
+
owner: "activeUserId",
|
|
36
|
+
ownerModel: "activeUserModelName",
|
|
37
|
+
};
|
|
38
|
+
const data = this.extractByInstructions(req, instructions);
|
|
39
|
+
return {
|
|
40
|
+
activeUser: req.user,
|
|
41
|
+
ip,
|
|
42
|
+
data,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
@@ -2,31 +2,31 @@ const notNode = require("not-node");
|
|
|
2
2
|
const { notValidationError } = require("not-error");
|
|
3
3
|
|
|
4
4
|
module.exports = async (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
);
|
|
5
|
+
/**
|
|
6
|
+
* Values to validate in form
|
|
7
|
+
*/
|
|
8
|
+
{owner, ownerModel, vals, to , validate },
|
|
9
|
+
/**
|
|
10
|
+
* special container to pass around global validation libs, CONSTs and inject other entities
|
|
11
|
+
*/
|
|
12
|
+
validationEnvs
|
|
13
|
+
) => {
|
|
14
|
+
//some preparations
|
|
15
|
+
if (
|
|
16
|
+
//vals checks
|
|
17
|
+
) {
|
|
18
|
+
throw new notValidationError(
|
|
19
|
+
"<%- ModuleName %>:validation_error",
|
|
20
|
+
{
|
|
21
|
+
//vals: ["%- ModuleName %>:vals_should_be_valid"],
|
|
22
|
+
},
|
|
23
|
+
undefined, //no source error, its custom exception
|
|
24
|
+
{
|
|
25
|
+
//information
|
|
26
|
+
//vals,
|
|
27
|
+
//owner,
|
|
28
|
+
//ownerModel
|
|
31
29
|
}
|
|
32
|
-
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
};
|