not-node 6.3.30 → 6.3.32
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/.prettierignore +1 -0
- package/package.json +1 -1
- package/src/bootstrap/route.js +2 -2
- package/src/cli/actions/entity.mjs +7 -3
- package/src/cli/lib/entity.mjs +11 -1
- package/src/cli/lib/fs.mjs +17 -0
- package/src/cli/lib/opts.mjs +15 -4
- package/src/cli/readers/entityData.mjs +4 -0
- package/src/core/fields/identity.js +12 -0
- package/src/core/fields/validators/identity.js +64 -0
- package/src/form/form.js +7 -5
- package/src/model/default.js +5 -1
- package/src/model/versioning.js +1 -1
- package/tmpl/files/module.server/layers/forms/create.ejs +4 -6
- package/tmpl/files/module.server/layers/forms/update.ejs +3 -2
- package/tmpl/files/module.server/layers/forms.ejs +2 -5
- package/tmpl/files/module.server/layers/logics.ejs +56 -60
- package/tmpl/files/module.server/layers/routes.ejs +30 -30
package/.prettierignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.ejs
|
package/package.json
CHANGED
package/src/bootstrap/route.js
CHANGED
|
@@ -87,8 +87,8 @@ module.exports = ({
|
|
|
87
87
|
|
|
88
88
|
const createDefaultForm = function ({ actionName, MODULE_NAME }) {
|
|
89
89
|
const FIELDS = [
|
|
90
|
-
["identity", "not-node//
|
|
91
|
-
["data", `${MODULE_NAME}//
|
|
90
|
+
["identity", "not-node//identity"],
|
|
91
|
+
["data", `${MODULE_NAME}//_${MODEL_NAME}`],
|
|
92
92
|
];
|
|
93
93
|
const FORM_NAME = `${MODULE_NAME}:${firstLetterToUpper(
|
|
94
94
|
actionName
|
|
@@ -3,6 +3,7 @@ import { resolve } from "node:path";
|
|
|
3
3
|
import { createEntity } from "../lib/entity.mjs";
|
|
4
4
|
import Logger from "../lib/log.mjs";
|
|
5
5
|
import { loadProjectConfig } from "../lib/project.mjs";
|
|
6
|
+
import { getProjectSiteDir } from "../lib/fs.mjs";
|
|
6
7
|
|
|
7
8
|
export default (program, { CWD }) => {
|
|
8
9
|
program
|
|
@@ -10,14 +11,17 @@ export default (program, { CWD }) => {
|
|
|
10
11
|
.addOption(
|
|
11
12
|
new Option("-v, --verbose").default(false, "extensive output")
|
|
12
13
|
)
|
|
14
|
+
.addOption(
|
|
15
|
+
new Option("-d, --dir <dir>").default("", "project site directory")
|
|
16
|
+
)
|
|
13
17
|
.description("adds entity to existing module of project")
|
|
14
18
|
.action(async (opts) => {
|
|
15
|
-
console.log(CWD);
|
|
16
|
-
const siteDir =
|
|
19
|
+
console.log(CWD, opts);
|
|
20
|
+
const siteDir = getProjectSiteDir(opts.dir, CWD);
|
|
21
|
+
console.log("project in", siteDir);
|
|
17
22
|
if (opts.v) {
|
|
18
23
|
Logger.setSilent(false);
|
|
19
24
|
}
|
|
20
|
-
console.log("project in", opts.dir);
|
|
21
25
|
const infoFromManifest = await loadProjectConfig(siteDir);
|
|
22
26
|
const modulesDir = resolve(
|
|
23
27
|
siteDir,
|
package/src/cli/lib/entity.mjs
CHANGED
|
@@ -22,6 +22,15 @@ async function renderEntityFiles(module_src_dir, data, config) {
|
|
|
22
22
|
console.error("No renderer for layer: ", layerName);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
if (data.layers.includes("controllers") && Renderers.controllersCommons) {
|
|
26
|
+
Renderers.controllersCommons(
|
|
27
|
+
resolve(module_src_dir, `./controllers/common`),
|
|
28
|
+
[data],
|
|
29
|
+
config,
|
|
30
|
+
renderFile,
|
|
31
|
+
Options.PATH_TMPL
|
|
32
|
+
);
|
|
33
|
+
}
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
async function createEntity(modules_dir, config) {
|
|
@@ -30,12 +39,13 @@ async function createEntity(modules_dir, config) {
|
|
|
30
39
|
const moduleDir = resolve(modules_dir, ModuleName);
|
|
31
40
|
const moduleLayers = await Readers.moduleLayers(inquirer);
|
|
32
41
|
const moduleConfig = { ...config, moduleName, ModuleName, moduleLayers };
|
|
33
|
-
console.log();
|
|
42
|
+
console.log("moduleConfig", moduleConfig);
|
|
34
43
|
const entityData = await Readers.entityData(
|
|
35
44
|
inquirer,
|
|
36
45
|
moduleConfig,
|
|
37
46
|
moduleConfig.moduleLayers
|
|
38
47
|
);
|
|
48
|
+
console.log("entityData", entityData);
|
|
39
49
|
await renderEntityFiles(
|
|
40
50
|
resolve(moduleDir, "./src"),
|
|
41
51
|
entityData,
|
package/src/cli/lib/fs.mjs
CHANGED
|
@@ -54,6 +54,22 @@ async function copyTmplFile(from, to) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
function getProjectSiteDir(dir, CWD) {
|
|
58
|
+
if (dir === "") {
|
|
59
|
+
return resolve(CWD, "./site");
|
|
60
|
+
} else {
|
|
61
|
+
if (
|
|
62
|
+
(dir.indexOf("/") > -1 || dir.indexOf("\\") > -1) &&
|
|
63
|
+
dir !== "./" &&
|
|
64
|
+
dir !== ".\\"
|
|
65
|
+
) {
|
|
66
|
+
return dir;
|
|
67
|
+
} else {
|
|
68
|
+
return resolve(CWD, dir);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
57
73
|
async function createDir(dirPath) {
|
|
58
74
|
try {
|
|
59
75
|
//console.log("mkdir", dirPath);
|
|
@@ -173,4 +189,5 @@ export {
|
|
|
173
189
|
buildClientSideScripts,
|
|
174
190
|
installPackages,
|
|
175
191
|
readJSONFile,
|
|
192
|
+
getProjectSiteDir,
|
|
176
193
|
};
|
package/src/cli/lib/opts.mjs
CHANGED
|
@@ -4,14 +4,25 @@ import * as url from "url";
|
|
|
4
4
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
5
5
|
|
|
6
6
|
class Options {
|
|
7
|
-
#
|
|
7
|
+
#DEFAULT_SITE_PATH = "./site";
|
|
8
|
+
get DEFAULT_SITE_PATH() {
|
|
9
|
+
return this.#DEFAULT_SITE_PATH;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
#DEFAULT_SERVER_MODULES_SUB_PATH = "./app/server/modules";
|
|
8
13
|
get DEFAULT_SERVER_MODULES_SUB_PATH() {
|
|
9
|
-
return
|
|
14
|
+
return resolve(
|
|
15
|
+
this.DEFAULT_SITE_PATH,
|
|
16
|
+
this.#DEFAULT_SERVER_MODULES_SUB_PATH
|
|
17
|
+
);
|
|
10
18
|
}
|
|
11
19
|
|
|
12
|
-
#DEFAULT_FRONT_MODULES_SUB_PATH = "./
|
|
20
|
+
#DEFAULT_FRONT_MODULES_SUB_PATH = "./app/front/src";
|
|
13
21
|
get DEFAULT_FRONT_MODULES_SUB_PATH() {
|
|
14
|
-
return
|
|
22
|
+
return resolve(
|
|
23
|
+
this.DEFAULT_SITE_PATH,
|
|
24
|
+
this.#DEFAULT_FRONT_MODULES_SUB_PATH
|
|
25
|
+
);
|
|
15
26
|
}
|
|
16
27
|
|
|
17
28
|
#PATH_TMPL = resolve(__dirname, "../../../tmpl/files");
|
|
@@ -37,6 +37,10 @@ export default (inquirer, config, layersList) => {
|
|
|
37
37
|
result.validators = await modelValidators(inquirer);
|
|
38
38
|
result.versioning = await modelVersioning(inquirer);
|
|
39
39
|
result.increment = await modelIncrement(inquirer, result);
|
|
40
|
+
} else {
|
|
41
|
+
result.increment = false;
|
|
42
|
+
result.versioning = false;
|
|
43
|
+
result.validators = true;
|
|
40
44
|
}
|
|
41
45
|
console.log("Entity data", JSON.stringify(result));
|
|
42
46
|
return result;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const { objHas } = require("../../../common");
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
{
|
|
5
|
+
validator(val) {
|
|
6
|
+
return objHas(val, "root") && typeof val.root == "boolean";
|
|
7
|
+
},
|
|
8
|
+
message: "not-node:identity_field_root_is_not_valid",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
validator(val) {
|
|
12
|
+
return objHas(val, "admin") && typeof val.admin == "boolean";
|
|
13
|
+
},
|
|
14
|
+
message: "not-node:identity_field_admin_is_not_valid",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
validator(val) {
|
|
18
|
+
return objHas(val, "auth") && typeof val.auth == "boolean";
|
|
19
|
+
},
|
|
20
|
+
message: "not-node:identity_field_auth_is_not_valid",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
validator(val) {
|
|
24
|
+
return (
|
|
25
|
+
objHas(val, "role") &&
|
|
26
|
+
(typeof val.role === "string" || Array.isArray(val.role))
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
message: "not-node:identity_field_role_is_not_valid",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
validator(val) {
|
|
33
|
+
return (
|
|
34
|
+
objHas(val, "primaryRole") &&
|
|
35
|
+
typeof val.primaryRole === "string"
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
message: "not-node:identity_field_primaryRole_is_not_valid",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
validator(val) {
|
|
42
|
+
return objHas(val, "uid");
|
|
43
|
+
},
|
|
44
|
+
message: "not-node:identity_field_uid_is_undefined",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
validator(val) {
|
|
48
|
+
return objHas(val, "sid");
|
|
49
|
+
},
|
|
50
|
+
message: "not-node:identity_field_sid_is_undefined",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
validator(val) {
|
|
54
|
+
return objHas(val, "ip") && typeof val.ip === "string";
|
|
55
|
+
},
|
|
56
|
+
message: "not-node:identity_field_ip_is_not_valid",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
validator(val) {
|
|
60
|
+
return objHas(val, "provider") && typeof val.provider === "string";
|
|
61
|
+
},
|
|
62
|
+
message: "not-node:identity_field_provider_is_not_valid",
|
|
63
|
+
},
|
|
64
|
+
];
|
package/src/form/form.js
CHANGED
|
@@ -24,7 +24,8 @@ const DEFAULT_TRANSFORMERS = require("./transformers");
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Generic form validation class
|
|
27
|
-
|
|
27
|
+
* @class Form
|
|
28
|
+
*/
|
|
28
29
|
class Form {
|
|
29
30
|
/**
|
|
30
31
|
* @prop {import('not-validation/src/builder').notValidationSchema} validation schema
|
|
@@ -38,10 +39,11 @@ class Form {
|
|
|
38
39
|
* @prop {string} name of form
|
|
39
40
|
**/
|
|
40
41
|
#FORM_NAME;
|
|
42
|
+
|
|
41
43
|
#MODEL_NAME;
|
|
42
44
|
#MODULE_NAME;
|
|
43
45
|
#PROTO_FIELDS;
|
|
44
|
-
|
|
46
|
+
|
|
45
47
|
#EXTRACTORS = {
|
|
46
48
|
...DEFAULT_EXTRACTORS,
|
|
47
49
|
};
|
|
@@ -186,7 +188,7 @@ class Form {
|
|
|
186
188
|
);
|
|
187
189
|
if (!validationResult.clean) {
|
|
188
190
|
throw new notValidationError(
|
|
189
|
-
"not-
|
|
191
|
+
"not-node:form_validation_error",
|
|
190
192
|
validationResult.getReport(),
|
|
191
193
|
null,
|
|
192
194
|
data
|
|
@@ -197,7 +199,7 @@ class Form {
|
|
|
197
199
|
throw e;
|
|
198
200
|
} else {
|
|
199
201
|
throw new notError(
|
|
200
|
-
"not-
|
|
202
|
+
"not-node:form_validation_unknown_error",
|
|
201
203
|
{
|
|
202
204
|
FORM_NAME: this.#FORM_NAME,
|
|
203
205
|
PROTO_FIELDS: this.#PROTO_FIELDS,
|
|
@@ -305,7 +307,7 @@ class Form {
|
|
|
305
307
|
throw e;
|
|
306
308
|
} else {
|
|
307
309
|
throw new notError(
|
|
308
|
-
"
|
|
310
|
+
"not-node:form_validation_error",
|
|
309
311
|
{
|
|
310
312
|
FORM_NAME: this.#FORM_NAME,
|
|
311
313
|
PROTO_FIELDS: this.#PROTO_FIELDS,
|
package/src/model/default.js
CHANGED
|
@@ -394,7 +394,11 @@ function close(data = undefined) {
|
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
function saveNewVersion() {
|
|
397
|
-
return routine.update(
|
|
397
|
+
return routine.update(
|
|
398
|
+
this.constructor,
|
|
399
|
+
{ _id: this._id },
|
|
400
|
+
this.toObject({ minimize: false })
|
|
401
|
+
);
|
|
398
402
|
}
|
|
399
403
|
|
|
400
404
|
module.exports.thisMethods = {
|
package/src/model/versioning.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
const getIP = require("not-node").Auth.getIP;
|
|
2
1
|
const { MODULE_NAME } = require("../const");
|
|
3
2
|
//DB related validation tools
|
|
4
3
|
const Form = require("not-node").Form;
|
|
5
4
|
//form
|
|
5
|
+
|
|
6
6
|
const FIELDS = [
|
|
7
|
-
["
|
|
7
|
+
["identity", "not-node//identity"],
|
|
8
8
|
["data", `${MODULE_NAME}//_<%- ModelName %>_data`],
|
|
9
|
-
["ip", "not-node//ip"],
|
|
10
9
|
];
|
|
11
10
|
|
|
12
11
|
const FORM_NAME = `${MODULE_NAME}:<%- ModelName %>CreateForm`;
|
|
@@ -21,15 +20,14 @@ const FIELDS = [
|
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Extracts data
|
|
24
|
-
* @param {
|
|
23
|
+
* @param {import('not-node/src/types.js').notNodeExpressRequest} req expressjs request object
|
|
25
24
|
* @return {Object} forma data
|
|
26
25
|
**/
|
|
27
26
|
extract(req) {
|
|
28
|
-
const ip = getIP(req);
|
|
29
27
|
const instructions = {
|
|
30
28
|
<% if (fields && Array.isArray(fields)) { %>
|
|
31
29
|
<% for(let field of fields){ %>
|
|
32
|
-
<%- field+': fromBody" ,' -%>
|
|
30
|
+
<%- field+': "fromBody" ,' -%>
|
|
33
31
|
<% } %>
|
|
34
32
|
<% } %>
|
|
35
33
|
owner: "activeUserId",
|
|
@@ -10,7 +10,7 @@ const FIELDS = [
|
|
|
10
10
|
];
|
|
11
11
|
const FORM_NAME = `${MODULE_NAME}:<%- ModelName %>UpdateForm`;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
class <%- ModelName %>UpdateForm extends Form {
|
|
14
14
|
constructor({ app }) {
|
|
15
15
|
super({ FIELDS, FORM_NAME, app });
|
|
16
16
|
}
|
|
@@ -37,4 +37,5 @@ const FIELDS = [
|
|
|
37
37
|
ip: getIP(req),
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|
|
41
|
+
module.exports = <%- ModelName %>UpdateForm;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
const { MODULE_NAME } = require("../const");
|
|
2
2
|
//DB related validation tools
|
|
3
3
|
const Form = require("not-node").Form;
|
|
4
|
-
//not-node
|
|
5
|
-
const getIP = require("not-node").Auth.getIP;
|
|
6
4
|
//form
|
|
7
5
|
const FIELDS = [
|
|
8
|
-
["
|
|
9
|
-
["data", `${MODULE_NAME}//_data`],
|
|
10
|
-
["ip", "not-node//ip"],
|
|
6
|
+
["identity", "not-node//identity"],
|
|
7
|
+
["data", `${MODULE_NAME}//_data`],
|
|
11
8
|
];
|
|
12
9
|
|
|
13
10
|
const FORM_NAME = `${MODULE_NAME}:CreateForm`;
|
|
@@ -1,73 +1,69 @@
|
|
|
1
1
|
const MODEL_NAME = "<%- ModelName %>";
|
|
2
|
-
|
|
3
2
|
const { MODULE_NAME } = require("../const.js");
|
|
4
3
|
const notNode = require("not-node");
|
|
5
|
-
|
|
6
4
|
const {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} = notNode.Bootstrap.notBootstrapLogic({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
5
|
+
Log,
|
|
6
|
+
LogAction,
|
|
7
|
+
say,
|
|
8
|
+
phrase,
|
|
9
|
+
config,
|
|
10
|
+
getModel,
|
|
11
|
+
getModelSchema,
|
|
12
|
+
getLogic,
|
|
13
|
+
getModelUser,
|
|
14
|
+
} = notNode.Bootstrap.notBootstrapLogic({
|
|
15
|
+
target: module,
|
|
16
|
+
MODEL_NAME,
|
|
17
|
+
MODULE_NAME,
|
|
18
|
+
});
|
|
21
19
|
|
|
22
20
|
const populateBuilders = {};
|
|
23
21
|
|
|
24
22
|
const <%- ModelName %>GenericLogic = notNode.Generic.GenericLogic({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
|
|
23
|
+
MODEL_NAME,
|
|
24
|
+
MODULE_NAME,
|
|
25
|
+
Log,
|
|
26
|
+
LogAction,
|
|
27
|
+
say,
|
|
28
|
+
phrase,
|
|
29
|
+
config,
|
|
30
|
+
getModel,
|
|
31
|
+
getModelSchema,
|
|
32
|
+
getLogic,
|
|
33
|
+
getModelUser,
|
|
34
|
+
populateBuilders,
|
|
35
|
+
});
|
|
36
|
+
|
|
39
37
|
module.exports.thisLogicName = MODEL_NAME;
|
|
40
38
|
|
|
41
39
|
class <%- ModelName %>Logic extends <%- ModelName %>GenericLogic {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<% } %>
|
|
70
|
-
<% } %>
|
|
40
|
+
<% if(Object.keys(actions).length){ %>
|
|
41
|
+
<% for(let actionName in actions) { %>
|
|
42
|
+
static async <%- actionName %>({ identity, data, targetId, shouldOwn }) {
|
|
43
|
+
const action = "<%- actionName %>";
|
|
44
|
+
Log.debug(
|
|
45
|
+
`${MODULE_NAME}//Logic//${MODEL_NAME}//${action}`,
|
|
46
|
+
targetId,
|
|
47
|
+
ip: identity.ip,
|
|
48
|
+
root: identity.root,
|
|
49
|
+
);
|
|
50
|
+
const results = await getModel().<%- actionName %>(
|
|
51
|
+
targetId,
|
|
52
|
+
data,
|
|
53
|
+
identity
|
|
54
|
+
);
|
|
55
|
+
LogAction({
|
|
56
|
+
action,
|
|
57
|
+
by: identity.uid,
|
|
58
|
+
role: identity.role,
|
|
59
|
+
ip: identity.ip,
|
|
60
|
+
root: identity.root,
|
|
61
|
+
shouldOwn,
|
|
62
|
+
});
|
|
63
|
+
return results;
|
|
64
|
+
}
|
|
65
|
+
<% } %>
|
|
66
|
+
<% } %>
|
|
71
67
|
}
|
|
72
68
|
|
|
73
|
-
module.exports[MODEL_NAME] = <%- ModelName %>Logic;
|
|
69
|
+
module.exports[MODEL_NAME] = <%- ModelName %>Logic;
|
|
@@ -3,45 +3,45 @@ const MODEL_NAME = "<%- ModelName %>";
|
|
|
3
3
|
const notNode = require("not-node");
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
// say,
|
|
7
|
+
// config,
|
|
8
|
+
// Log,
|
|
9
|
+
before,
|
|
10
|
+
after,
|
|
11
|
+
getLogic,
|
|
12
|
+
// getModel,
|
|
13
|
+
// getModelSchema,
|
|
14
14
|
} = notNode.Bootstrap.notBootstrapRoute({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
target: module,
|
|
16
|
+
MODEL_NAME,
|
|
17
|
+
MODULE_NAME,
|
|
18
|
+
defaultAccessRule: true,
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
const <%- ModelName %>GenericRoute = notNode.Generic.GenericRoute({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
before, //<-this prepares `prepared`
|
|
23
|
+
after,
|
|
24
|
+
getLogic,
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
class <%- ModelName %>Route extends <%- ModelName %>GenericRoute {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
<% if(Object.keys(actions).length){ %>
|
|
29
|
+
<% for(let actionName in actions) { %>
|
|
30
|
+
static async <%- actionName %>(
|
|
31
|
+
req, res, next, //standart express routes objects
|
|
32
|
+
prepared //extracted by `before` if form class exists
|
|
33
|
+
) {
|
|
34
|
+
<% if (layers.includes('forms') && layers.includes('logics')){ %>
|
|
35
|
+
return await getLogic().<%- actionName %>({ ...prepared });
|
|
36
|
+
<% } %>
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
<% if (layers.includes('forms') && !layers.includes('logics')){ %>
|
|
39
|
+
return {...prepared};
|
|
40
|
+
<% } %>
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
<% if (!layers.includes('forms') && layers.includes('logics')){ %>
|
|
43
|
+
return await getLogic().<%- actionName %>();
|
|
44
|
+
<% } %>
|
|
45
45
|
}
|
|
46
46
|
<% } %>
|
|
47
47
|
<% } %>
|