not-node 6.0.7 → 6.1.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.
- package/bin/not-builder.js +418 -293
- package/bin/not-cli.mjs +369 -0
- package/index.js +6 -0
- package/package.json +133 -128
- package/playground/.babelrc +11 -0
- package/playground/.eslintignore +4 -0
- package/playground/.eslintrc.json +23 -0
- package/playground/app/front/index.!.js +64 -0
- package/playground/app/front/rollup.!.js +70 -0
- package/playground/app/front/src/admin/main/index.js +45 -0
- package/playground/app/front/src/client/main/index.js +45 -0
- package/playground/app/front/src/common/index.js +39 -0
- package/playground/app/front/src/common/ncInit.js +18 -0
- package/playground/app/front/src/common/ws.client.main.js +35 -0
- package/playground/app/front/src/guest/main/index.js +34 -0
- package/playground/app/front/src/root/main/index.js +45 -0
- package/playground/app/front/src/user/main/index.js +45 -0
- package/playground/app/server/app.js +22 -0
- package/playground/app/server/config/common.json +53 -0
- package/playground/app/server/config/development.json +34 -0
- package/playground/app/server/config/production.json +34 -0
- package/playground/app/server/config/stage.json +34 -0
- package/playground/app/server/index.js +20 -0
- package/playground/app/server/routes/index.js +36 -0
- package/playground/app/server/routes/site.js +71 -0
- package/playground/app/server/views/admin/foot.pug +1 -0
- package/playground/app/server/views/admin/head.pug +7 -0
- package/playground/app/server/views/admin/menu.pug +2 -0
- package/playground/app/server/views/admin.pug +19 -0
- package/playground/app/server/views/dashboard.pug +20 -0
- package/playground/app/server/views/index.pug +15 -0
- package/playground/app/server/views/parts/header.android.pug +7 -0
- package/playground/app/server/views/parts/header.ios.pug +5 -0
- package/playground/app/server/views/parts/header.pug +18 -0
- package/playground/app/server/views/parts/menu.pug +1 -0
- package/playground/app/server/views/parts/overview.pug +2 -0
- package/playground/app/server/ws/auth.js +41 -0
- package/playground/app/server/ws/index.js +84 -0
- package/playground/bin/build.sh +8 -0
- package/playground/package.json +66 -0
- package/playground/project.manifest.json +34 -0
- package/src/app.js +3 -3
- package/src/cli/const.mjs +71 -0
- package/src/cli/readers/AppDescription.mjs +14 -0
- package/src/cli/readers/AppName.mjs +14 -0
- package/src/cli/readers/ModelName.mjs +14 -0
- package/src/cli/readers/ModuleName.mjs +14 -0
- package/src/cli/readers/actions.mjs +25 -0
- package/src/cli/readers/appName.mjs +14 -0
- package/src/cli/readers/cors.mjs +12 -0
- package/src/cli/readers/db/ioredis.mjs +3 -0
- package/src/cli/readers/db/mongoose.mjs +61 -0
- package/src/cli/readers/db/redis.mjs +3 -0
- package/src/cli/readers/db.mjs +30 -0
- package/src/cli/readers/entityData.mjs +44 -0
- package/src/cli/readers/entityLayers.mjs +21 -0
- package/src/cli/readers/fields.mjs +13 -0
- package/src/cli/readers/filter.mjs +34 -0
- package/src/cli/readers/hostname.mjs +23 -0
- package/src/cli/readers/index.mjs +86 -0
- package/src/cli/readers/init_root_user.mjs +55 -0
- package/src/cli/readers/isUserNeedCreateEntity.mjs +14 -0
- package/src/cli/readers/isUserNeedCreateServerModule.mjs +14 -0
- package/src/cli/readers/isUserNeedFrontModuleBootstrap.mjs +14 -0
- package/src/cli/readers/modelIncrement.mjs +32 -0
- package/src/cli/readers/modelIncrementFilter.mjs +49 -0
- package/src/cli/readers/modelOptions.mjs +61 -0
- package/src/cli/readers/modelValidators.mjs +14 -0
- package/src/cli/readers/modelVersioning.mjs +14 -0
- package/src/cli/readers/moduleLayers.mjs +25 -0
- package/src/cli/readers/modules.mjs +19 -0
- package/src/cli/readers/not_node_monitor.mjs +48 -0
- package/src/cli/readers/not_node_reporter.mjs +42 -0
- package/src/cli/readers/port.mjs +14 -0
- package/src/cli/readers/roles.mjs +25 -0
- package/src/cli/readers/rolesSecondary.mjs +14 -0
- package/src/cli/readers/secret.mjs +21 -0
- package/src/cli/readers/session.mjs +55 -0
- package/src/cli/readers/ssl.mjs +38 -0
- package/src/cli/readers/user.mjs +62 -0
- package/src/cli/readers/ws.mjs +35 -0
- package/src/cli/renderers/controllers.mjs +26 -0
- package/src/cli/renderers/controllersCommons.mjs +42 -0
- package/src/cli/renderers/controllersIndex.mjs +18 -0
- package/src/cli/renderers/fields.mjs +1 -0
- package/src/cli/renderers/forms.mjs +43 -0
- package/src/cli/renderers/frontModuleGuestMain.mjs +10 -0
- package/src/cli/renderers/frontModuleRoleMain.mjs +10 -0
- package/src/cli/renderers/index.mjs +29 -0
- package/src/cli/renderers/logics.mjs +17 -0
- package/src/cli/renderers/models.mjs +16 -0
- package/src/cli/renderers/routes.mjs +31 -0
- package/src/domain.js +8 -9
- package/src/headers.js +17 -0
- package/src/identity/identity.js +0 -1
- package/src/init/index.js +1 -0
- package/src/init/lib/app.js +5 -7
- package/src/init/lib/modules.js +2 -1
- package/src/init/lib/routes.js +1 -0
- package/src/manifest/module.js +6 -20
- package/src/metas.js +34 -0
- package/src/styler.js +38 -0
- package/tmpl/dirs/app.mjs +32 -0
- package/tmpl/dirs/front.mjs +12 -0
- package/tmpl/dirs/module.front.mjs +19 -0
- package/tmpl/dirs/module.server.controllers.common.mjs +7 -0
- package/tmpl/dirs/module.server.mjs +14 -0
- package/tmpl/dirs/server.mjs +127 -0
- package/tmpl/dirs/static.mjs +9 -0
- package/tmpl/files/app/.babelrc +11 -0
- package/tmpl/files/app/.eslintignore +4 -0
- package/tmpl/files/app/.eslintrc.json +23 -0
- package/tmpl/files/app/app.ejs +22 -0
- package/tmpl/files/app/build.sh +8 -0
- package/tmpl/files/app/config/common.ejs +131 -0
- package/tmpl/files/app/config/other.ejs +34 -0
- package/tmpl/files/app/deploy.pm2.ejs +23 -0
- package/tmpl/files/app/env.ejs +16 -0
- package/tmpl/files/app/front/build.env.ejs +7 -0
- package/tmpl/files/app/front/index.!.ejs +66 -0
- package/tmpl/files/app/front/rollup.!.ejs +70 -0
- package/tmpl/files/app/index.ejs +20 -0
- package/tmpl/files/app/package.ejs +66 -0
- package/tmpl/files/app/project.manifest.ejs +23 -0
- package/tmpl/files/app/routes/index.ejs +36 -0
- package/tmpl/files/app/routes/site.ejs +71 -0
- package/tmpl/files/app/views/admin/foot.ejs +1 -0
- package/tmpl/files/app/views/admin/head.ejs +7 -0
- package/tmpl/files/app/views/admin/menu.ejs +2 -0
- package/tmpl/files/app/views/admin.ejs +19 -0
- package/tmpl/files/app/views/dashboard.ejs +20 -0
- package/tmpl/files/app/views/index.ejs +15 -0
- package/tmpl/files/app/views/parts/header.android.ejs +7 -0
- package/tmpl/files/app/views/parts/header.ejs +18 -0
- package/tmpl/files/app/views/parts/header.ios.ejs +5 -0
- package/tmpl/files/app/views/parts/menu.ejs +1 -0
- package/tmpl/files/app/views/parts/overview.ejs +2 -0
- package/tmpl/files/app/ws/auth.ejs +41 -0
- package/tmpl/files/app/ws/index.ejs +84 -0
- package/tmpl/files/module.front/common/index.ejs +39 -0
- package/tmpl/files/module.front/common/ncInit.ejs +18 -0
- package/tmpl/files/module.front/common/ws.client.main.ejs +35 -0
- package/tmpl/files/module.front/role/guest.index.ejs +45 -0
- package/tmpl/files/module.front/role/index.ejs +34 -0
- package/tmpl/files/module.server/const.ejs +1 -0
- package/{scaffold/base.js → tmpl/files/module.server/extractor.ejs} +0 -0
- package/tmpl/files/module.server/index.ejs +8 -0
- package/tmpl/files/module.server/layers/controllers/common/crud.ejs +95 -0
- package/tmpl/files/module.server/layers/controllers/common/index.ejs +59 -0
- package/tmpl/files/module.server/layers/controllers/common/validators.ejs +44 -0
- package/tmpl/files/module.server/layers/controllers/common/ws.client.ejs +25 -0
- package/tmpl/files/module.server/layers/controllers/role/crud.ejs +11 -0
- package/tmpl/files/module.server/layers/controllers/role/index.ejs +29 -0
- package/tmpl/files/module.server/layers/fields.ejs +30 -0
- package/tmpl/files/module.server/layers/forms/_data.ejs +35 -0
- package/tmpl/files/module.server/layers/forms/create.ejs +47 -0
- package/tmpl/files/module.server/layers/forms/delete.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/get.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/getRaw.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/listAll.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/listAndCount.ejs +8 -0
- package/tmpl/files/module.server/layers/forms/update.ejs +40 -0
- package/tmpl/files/module.server/layers/forms/validator.ejs +32 -0
- package/tmpl/files/module.server/layers/forms.ejs +49 -0
- package/tmpl/files/module.server/layers/locales.ejs +3 -0
- package/tmpl/files/module.server/layers/logics.ejs +73 -0
- package/tmpl/files/module.server/layers/models.ejs +68 -0
- package/tmpl/files/module.server/layers/routes.ejs +50 -0
- package/tmpl/files/module.server/layers/routes.manifest.ejs +211 -0
- package/tmpl/files/module.server/layers/routes.ws.ejs +29 -0
- package/tmpl/files/module.server/validationEnv.ejs +5 -0
- package/tmpl/files/notComponent.ejs +57 -0
- package/tmpl/files/notService.ejs +39 -0
- package/scaffold/field.js +0 -0
- package/scaffold/form.js +0 -0
- package/scaffold/logic.js +0 -0
- package/scaffold/model.js +0 -0
- package/scaffold/module.js +0 -0
- package/scaffold/route.js +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DEFAULT_NODE_API_URL } from "../const.mjs";
|
|
2
|
+
|
|
3
|
+
function collectNodeMonitor(inquirer) {
|
|
4
|
+
return inquirer.prompt([
|
|
5
|
+
{
|
|
6
|
+
type: "input",
|
|
7
|
+
name: "report_key",
|
|
8
|
+
message: "Report API Key",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
type: "input",
|
|
12
|
+
name: "report_url",
|
|
13
|
+
message: "Report API URL",
|
|
14
|
+
default: DEFAULT_NODE_API_URL,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: "input",
|
|
18
|
+
name: "report_interval",
|
|
19
|
+
message: "Report Interval (sec)",
|
|
20
|
+
default: 60,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: "input",
|
|
24
|
+
name: "interval",
|
|
25
|
+
message: "Monitor measurment interval (ms)",
|
|
26
|
+
default: 5000,
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default (inquirer) => {
|
|
32
|
+
inquirer
|
|
33
|
+
.prompt([
|
|
34
|
+
{
|
|
35
|
+
type: "confirm",
|
|
36
|
+
name: "enabled",
|
|
37
|
+
message: "Init monitoring",
|
|
38
|
+
default: false,
|
|
39
|
+
},
|
|
40
|
+
])
|
|
41
|
+
.then(({ enabled }) => {
|
|
42
|
+
if (enabled) {
|
|
43
|
+
return collectNodeMonitor(inquirer);
|
|
44
|
+
} else {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DEFAULT_NODE_API_URL } from "../const.mjs";
|
|
2
|
+
|
|
3
|
+
function collectNodeReporter(inquirer) {
|
|
4
|
+
return inquirer.prompt([
|
|
5
|
+
{
|
|
6
|
+
type: "input",
|
|
7
|
+
name: "key",
|
|
8
|
+
message: "Report API Key",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
type: "input",
|
|
12
|
+
name: "url_node",
|
|
13
|
+
message: "Report API URL for server side",
|
|
14
|
+
default: DEFAULT_NODE_API_URL,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: "input",
|
|
18
|
+
name: "url_browser",
|
|
19
|
+
message: "Report API URL for client side",
|
|
20
|
+
default: DEFAULT_NODE_API_URL,
|
|
21
|
+
},
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default (inquirer) => {
|
|
26
|
+
return inquirer
|
|
27
|
+
.prompt([
|
|
28
|
+
{
|
|
29
|
+
type: "confirm",
|
|
30
|
+
name: "enabled",
|
|
31
|
+
message: "Init error reporting",
|
|
32
|
+
default: false,
|
|
33
|
+
},
|
|
34
|
+
])
|
|
35
|
+
.then((answer) => {
|
|
36
|
+
if (answer.enabled) {
|
|
37
|
+
return collectNodeReporter(inquirer);
|
|
38
|
+
} else {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DEFAULT_PRIMARY_ROLES_SET } from "../const.mjs";
|
|
2
|
+
|
|
3
|
+
export default (inquirer) => {
|
|
4
|
+
return inquirer
|
|
5
|
+
.prompt([
|
|
6
|
+
{
|
|
7
|
+
type: "checkbox",
|
|
8
|
+
message: "Select primary user roles set",
|
|
9
|
+
name: "roles",
|
|
10
|
+
choices: DEFAULT_PRIMARY_ROLES_SET.map((role) => {
|
|
11
|
+
return {
|
|
12
|
+
name: role,
|
|
13
|
+
checked: true,
|
|
14
|
+
};
|
|
15
|
+
}),
|
|
16
|
+
validate(answer) {
|
|
17
|
+
if (answer.length < 1) {
|
|
18
|
+
return "You must choose at least one role.";
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
])
|
|
24
|
+
.then((answer) => answer.roles);
|
|
25
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default (inquirer) => {
|
|
2
|
+
return inquirer
|
|
3
|
+
.prompt([
|
|
4
|
+
{
|
|
5
|
+
type: "input",
|
|
6
|
+
name: "additional",
|
|
7
|
+
message: "Additional user roles",
|
|
8
|
+
default: "confirmed,manager",
|
|
9
|
+
},
|
|
10
|
+
])
|
|
11
|
+
.then((answers) => {
|
|
12
|
+
return answers.additional.split(",").map((entry) => entry.trim());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import generator from "generate-password";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_SECRET = generator.generate({
|
|
4
|
+
length: 40,
|
|
5
|
+
numbers: true,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export default (inquirer) => {
|
|
9
|
+
return inquirer
|
|
10
|
+
.prompt([
|
|
11
|
+
{
|
|
12
|
+
type: "input",
|
|
13
|
+
name: "name",
|
|
14
|
+
message: "Application General Secret Key",
|
|
15
|
+
default: DEFAULT_SECRET,
|
|
16
|
+
},
|
|
17
|
+
])
|
|
18
|
+
.then((answers) => {
|
|
19
|
+
return answers.name;
|
|
20
|
+
});
|
|
21
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import generator from "generate-password";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_SECRET = generator.generate({
|
|
4
|
+
length: 40,
|
|
5
|
+
numbers: true,
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
function collectData(inquirer) {
|
|
9
|
+
return inquirer.prompt([
|
|
10
|
+
{
|
|
11
|
+
type: "input",
|
|
12
|
+
name: "key",
|
|
13
|
+
message: "Session key",
|
|
14
|
+
default: "SessionID",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: "list",
|
|
18
|
+
name: "driver",
|
|
19
|
+
message: "Session store driver",
|
|
20
|
+
choices: ["mongoose", "redis"],
|
|
21
|
+
default: "redis",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: "input",
|
|
25
|
+
name: "secret",
|
|
26
|
+
message: "Session secret",
|
|
27
|
+
default: DEFAULT_SECRET,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: "input",
|
|
31
|
+
name: "ttl",
|
|
32
|
+
message: "Session Cookie Max Age",
|
|
33
|
+
default: 2628000000,
|
|
34
|
+
},
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default (inquirer) => {
|
|
39
|
+
return inquirer
|
|
40
|
+
.prompt([
|
|
41
|
+
{
|
|
42
|
+
type: "confirm",
|
|
43
|
+
name: "enabled",
|
|
44
|
+
message: "Configure Session module?",
|
|
45
|
+
default: false,
|
|
46
|
+
},
|
|
47
|
+
])
|
|
48
|
+
.then((answer) => {
|
|
49
|
+
if (answer.enabled) {
|
|
50
|
+
return collectData(inquirer);
|
|
51
|
+
} else {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
function collectData(inquirer) {
|
|
2
|
+
return inquirer.prompt([
|
|
3
|
+
{
|
|
4
|
+
type: "input",
|
|
5
|
+
name: "private",
|
|
6
|
+
message: "SSL private key",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
type: "input",
|
|
10
|
+
name: "fullchain",
|
|
11
|
+
message: "SSL fullchain",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
type: "input",
|
|
15
|
+
name: "chain",
|
|
16
|
+
message: "SSL chain",
|
|
17
|
+
},
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default (inquirer) => {
|
|
22
|
+
return inquirer
|
|
23
|
+
.prompt([
|
|
24
|
+
{
|
|
25
|
+
type: "confirm",
|
|
26
|
+
name: "enabled",
|
|
27
|
+
message: "SSL",
|
|
28
|
+
default: false,
|
|
29
|
+
},
|
|
30
|
+
])
|
|
31
|
+
.then((answer) => {
|
|
32
|
+
if (answer.enabled) {
|
|
33
|
+
return collectData(inquirer);
|
|
34
|
+
} else {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
function collectRestrictions(inquirer) {
|
|
2
|
+
return inquirer.prompt([
|
|
3
|
+
{
|
|
4
|
+
type: "confirm",
|
|
5
|
+
name: "registration",
|
|
6
|
+
message: "Restrict registration?",
|
|
7
|
+
default: false,
|
|
8
|
+
},
|
|
9
|
+
]);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function askToCollectRestrictions(inquirer) {
|
|
13
|
+
return inquirer
|
|
14
|
+
.prompt([
|
|
15
|
+
{
|
|
16
|
+
type: "confirm",
|
|
17
|
+
name: "enabled",
|
|
18
|
+
message: "Set User module restrictions?",
|
|
19
|
+
default: false,
|
|
20
|
+
},
|
|
21
|
+
])
|
|
22
|
+
.then((answer) => {
|
|
23
|
+
return answer.enabled;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function collectData(inquirer) {
|
|
28
|
+
return inquirer
|
|
29
|
+
.prompt([
|
|
30
|
+
{
|
|
31
|
+
type: "input",
|
|
32
|
+
name: "tokenTTL",
|
|
33
|
+
message: "User token TTL (sec)",
|
|
34
|
+
default: 3600,
|
|
35
|
+
},
|
|
36
|
+
])
|
|
37
|
+
.then(async (answer) => {
|
|
38
|
+
if (await askToCollectRestrictions(inquirer)) {
|
|
39
|
+
answer.restrict = await collectRestrictions(inquirer);
|
|
40
|
+
}
|
|
41
|
+
return answer;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default (inquirer) => {
|
|
46
|
+
return inquirer
|
|
47
|
+
.prompt([
|
|
48
|
+
{
|
|
49
|
+
type: "confirm",
|
|
50
|
+
name: "enabled",
|
|
51
|
+
message: "Configure User module?",
|
|
52
|
+
default: false,
|
|
53
|
+
},
|
|
54
|
+
])
|
|
55
|
+
.then((answer) => {
|
|
56
|
+
if (answer.enabled) {
|
|
57
|
+
return collectData(inquirer);
|
|
58
|
+
} else {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function collectData(inquirer) {
|
|
2
|
+
return inquirer.prompt([
|
|
3
|
+
{
|
|
4
|
+
type: "input",
|
|
5
|
+
name: "port",
|
|
6
|
+
message: "WS port number",
|
|
7
|
+
default: 33000,
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
type: "config",
|
|
11
|
+
name: "secure",
|
|
12
|
+
message: "WS secure",
|
|
13
|
+
default: true,
|
|
14
|
+
},
|
|
15
|
+
]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default (inquirer) => {
|
|
19
|
+
return inquirer
|
|
20
|
+
.prompt([
|
|
21
|
+
{
|
|
22
|
+
type: "confirm",
|
|
23
|
+
name: "enabled",
|
|
24
|
+
message: "Configure WS module `main` server connection?",
|
|
25
|
+
default: false,
|
|
26
|
+
},
|
|
27
|
+
])
|
|
28
|
+
.then((answer) => {
|
|
29
|
+
if (answer.enabled) {
|
|
30
|
+
return collectData(inquirer);
|
|
31
|
+
} else {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
const CRUD_CONTROLLER_TMPL = "./module.server/layers/controllers/role/crud.ejs";
|
|
3
|
+
|
|
4
|
+
export default async (
|
|
5
|
+
module_layer_dir,
|
|
6
|
+
data,
|
|
7
|
+
config,
|
|
8
|
+
createFileContent,
|
|
9
|
+
PATH_TMPL,
|
|
10
|
+
createDir
|
|
11
|
+
) => {
|
|
12
|
+
for (let roleName of config.roles) {
|
|
13
|
+
const TARGET_DIR_PATH = resolve(module_layer_dir, roleName);
|
|
14
|
+
await createDir(TARGET_DIR_PATH);
|
|
15
|
+
const TMPL_FILE_PATH = resolve(PATH_TMPL, CRUD_CONTROLLER_TMPL);
|
|
16
|
+
const DEST_FILE_PATH = resolve(
|
|
17
|
+
module_layer_dir,
|
|
18
|
+
roleName,
|
|
19
|
+
`nc${data.ModelName}.js`
|
|
20
|
+
);
|
|
21
|
+
await createFileContent(TMPL_FILE_PATH, DEST_FILE_PATH, {
|
|
22
|
+
...config,
|
|
23
|
+
...data,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
const TEMPLATES_DIR = "./module.server/layers/controllers/common";
|
|
3
|
+
|
|
4
|
+
export default async (
|
|
5
|
+
module_layer_dir,
|
|
6
|
+
entitiesList,
|
|
7
|
+
config,
|
|
8
|
+
createFileContent,
|
|
9
|
+
PATH_TMPL
|
|
10
|
+
) => {
|
|
11
|
+
for (let entityData of entitiesList) {
|
|
12
|
+
const TMPL_FILE_PATH = resolve(PATH_TMPL, TEMPLATES_DIR, `crud.ejs`);
|
|
13
|
+
const DEST_FILE_PATH = resolve(
|
|
14
|
+
module_layer_dir,
|
|
15
|
+
`nc${entityData.ModelName}Common.js`
|
|
16
|
+
);
|
|
17
|
+
await createFileContent(TMPL_FILE_PATH, DEST_FILE_PATH, {
|
|
18
|
+
...config,
|
|
19
|
+
...entityData,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (entitiesList.length) {
|
|
24
|
+
const TMPL_FILE_PATH_VALIDATORS = resolve(
|
|
25
|
+
PATH_TMPL,
|
|
26
|
+
TEMPLATES_DIR,
|
|
27
|
+
`validators.ejs`
|
|
28
|
+
);
|
|
29
|
+
const DEST_FILE_PATH_VALIDATORS = resolve(
|
|
30
|
+
module_layer_dir,
|
|
31
|
+
`validators.js`
|
|
32
|
+
);
|
|
33
|
+
await createFileContent(
|
|
34
|
+
TMPL_FILE_PATH_VALIDATORS,
|
|
35
|
+
DEST_FILE_PATH_VALIDATORS,
|
|
36
|
+
{
|
|
37
|
+
...config,
|
|
38
|
+
...entitiesList[0],
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
const CONTROLLER_INDEX_TMPL =
|
|
3
|
+
"./module.server/layers/controllers/role/index.ejs";
|
|
4
|
+
|
|
5
|
+
export default async (
|
|
6
|
+
module_layer_dir,
|
|
7
|
+
data,
|
|
8
|
+
config,
|
|
9
|
+
createFileContent,
|
|
10
|
+
PATH_TMPL
|
|
11
|
+
) => {
|
|
12
|
+
const TMPL_FILE_PATH = resolve(PATH_TMPL, CONTROLLER_INDEX_TMPL);
|
|
13
|
+
const DEST_FILE_PATH = resolve(module_layer_dir, `index.js`);
|
|
14
|
+
await createFileContent(TMPL_FILE_PATH, DEST_FILE_PATH, {
|
|
15
|
+
...config,
|
|
16
|
+
entities: data,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default async () => {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
const TEMPLATES_DIR = "./module.server/layers/forms";
|
|
3
|
+
|
|
4
|
+
async function renderEntityActionForm(createFileContent, SRC, DEST, data) {
|
|
5
|
+
await createFileContent(SRC, DEST, data);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default async (
|
|
9
|
+
module_layer_dir,
|
|
10
|
+
data,
|
|
11
|
+
config,
|
|
12
|
+
createFileContent,
|
|
13
|
+
PATH_TMPL
|
|
14
|
+
) => {
|
|
15
|
+
for (let actionName in data.actions) {
|
|
16
|
+
const TMPL_FILE_PATH = resolve(
|
|
17
|
+
PATH_TMPL,
|
|
18
|
+
TEMPLATES_DIR,
|
|
19
|
+
`${actionName}.ejs`
|
|
20
|
+
);
|
|
21
|
+
const DEST_FILE_PATH = resolve(
|
|
22
|
+
module_layer_dir,
|
|
23
|
+
`${data.modelName}.${actionName}.js`
|
|
24
|
+
);
|
|
25
|
+
await renderEntityActionForm(
|
|
26
|
+
createFileContent,
|
|
27
|
+
TMPL_FILE_PATH,
|
|
28
|
+
DEST_FILE_PATH,
|
|
29
|
+
{ ...config, ...data }
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
const TMPL_FILE_PATH_DATA = resolve(PATH_TMPL, TEMPLATES_DIR, `_data.ejs`);
|
|
33
|
+
const DEST_FILE_PATH_DATA = resolve(
|
|
34
|
+
module_layer_dir,
|
|
35
|
+
`_${data.modelName}_data.js`
|
|
36
|
+
);
|
|
37
|
+
await renderEntityActionForm(
|
|
38
|
+
createFileContent,
|
|
39
|
+
TMPL_FILE_PATH_DATA,
|
|
40
|
+
DEST_FILE_PATH_DATA,
|
|
41
|
+
{ ...config, ...data }
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
const TEMPLATES_FILE = "./module.front/role/guest.index.ejs";
|
|
3
|
+
|
|
4
|
+
export default async (module_dir, config, createFileContent, PATH_TMPL) => {
|
|
5
|
+
const TMPL_FILE_PATH = resolve(PATH_TMPL, TEMPLATES_FILE);
|
|
6
|
+
const DEST_FILE_PATH = resolve(module_dir, `index.js`);
|
|
7
|
+
await createFileContent(TMPL_FILE_PATH, DEST_FILE_PATH, {
|
|
8
|
+
...config,
|
|
9
|
+
});
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
const TEMPLATES_FILE = "./module.front/role/index.ejs";
|
|
3
|
+
|
|
4
|
+
export default async (module_dir, config, createFileContent, PATH_TMPL) => {
|
|
5
|
+
const TMPL_FILE_PATH = resolve(PATH_TMPL, TEMPLATES_FILE);
|
|
6
|
+
const DEST_FILE_PATH = resolve(module_dir, `index.js`);
|
|
7
|
+
await createFileContent(TMPL_FILE_PATH, DEST_FILE_PATH, {
|
|
8
|
+
...config,
|
|
9
|
+
});
|
|
10
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import forms from "./forms.mjs";
|
|
2
|
+
export { forms };
|
|
3
|
+
|
|
4
|
+
import routes from "./routes.mjs";
|
|
5
|
+
export { routes };
|
|
6
|
+
|
|
7
|
+
import logics from "./logics.mjs";
|
|
8
|
+
export { logics };
|
|
9
|
+
|
|
10
|
+
import fields from "./fields.mjs";
|
|
11
|
+
export { fields };
|
|
12
|
+
|
|
13
|
+
import models from "./models.mjs";
|
|
14
|
+
export { models };
|
|
15
|
+
|
|
16
|
+
import controllers from "./controllers.mjs";
|
|
17
|
+
export { controllers };
|
|
18
|
+
|
|
19
|
+
import controllersIndex from "./controllersIndex.mjs";
|
|
20
|
+
export { controllersIndex };
|
|
21
|
+
|
|
22
|
+
import controllersCommons from "./controllersCommons.mjs";
|
|
23
|
+
export { controllersCommons };
|
|
24
|
+
|
|
25
|
+
import frontModuleRoleMain from "./frontModuleRoleMain.mjs";
|
|
26
|
+
export { frontModuleRoleMain };
|
|
27
|
+
|
|
28
|
+
import frontModuleGuestMain from "./frontModuleGuestMain.mjs";
|
|
29
|
+
export { frontModuleGuestMain };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
const TEMPLATE_FILE = "./module.server/layers/logics.ejs";
|
|
3
|
+
|
|
4
|
+
export default async (
|
|
5
|
+
module_layer_dir,
|
|
6
|
+
data,
|
|
7
|
+
config,
|
|
8
|
+
createFileContent,
|
|
9
|
+
PATH_TMPL
|
|
10
|
+
) => {
|
|
11
|
+
const TMPL_FILE_PATH = resolve(PATH_TMPL, TEMPLATE_FILE);
|
|
12
|
+
const DEST_FILE_PATH = resolve(module_layer_dir, `${data.modelName}.js`);
|
|
13
|
+
await createFileContent(TMPL_FILE_PATH, DEST_FILE_PATH, {
|
|
14
|
+
...config,
|
|
15
|
+
...data,
|
|
16
|
+
});
|
|
17
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
const TEMPLATE_FILE = "./module.server/layers/models.ejs";
|
|
3
|
+
|
|
4
|
+
export default async (
|
|
5
|
+
module_layer_dir,
|
|
6
|
+
data,
|
|
7
|
+
config,
|
|
8
|
+
createFileContent,
|
|
9
|
+
PATH_TMPL
|
|
10
|
+
) => {
|
|
11
|
+
const TMPL_FILE_PATH = resolve(PATH_TMPL, TEMPLATE_FILE);
|
|
12
|
+
const DEST_FILE_PATH = resolve(module_layer_dir, `${data.modelName}.js`);
|
|
13
|
+
const args = { ...config, ...data };
|
|
14
|
+
console.log(JSON.stringify(args, null, 4));
|
|
15
|
+
await createFileContent(TMPL_FILE_PATH, DEST_FILE_PATH, args);
|
|
16
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
const TEMPLATE_FILE = "./module.server/layers/routes.ejs";
|
|
3
|
+
const TEMPLATE_FILE_MANIFEST = "./module.server/layers/routes.manifest.ejs";
|
|
4
|
+
const TEMPLATE_FILE_WS = "./module.server/layers/routes.ws.ejs";
|
|
5
|
+
|
|
6
|
+
export default async (
|
|
7
|
+
module_layer_dir,
|
|
8
|
+
data,
|
|
9
|
+
config,
|
|
10
|
+
createFileContent,
|
|
11
|
+
PATH_TMPL
|
|
12
|
+
) => {
|
|
13
|
+
await createFileContent(
|
|
14
|
+
resolve(PATH_TMPL, TEMPLATE_FILE),
|
|
15
|
+
resolve(module_layer_dir, `${data.modelName}.js`),
|
|
16
|
+
{ ...config, ...data }
|
|
17
|
+
);
|
|
18
|
+
await createFileContent(
|
|
19
|
+
resolve(PATH_TMPL, TEMPLATE_FILE_MANIFEST),
|
|
20
|
+
resolve(module_layer_dir, `${data.modelName}.manifest.js`),
|
|
21
|
+
{ ...config, ...data }
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
if (config.modules.includes("not-ws")) {
|
|
25
|
+
await createFileContent(
|
|
26
|
+
resolve(PATH_TMPL, TEMPLATE_FILE_WS),
|
|
27
|
+
resolve(module_layer_dir, `${data.modelName}.ws.js`),
|
|
28
|
+
{ ...config, ...data }
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
};
|
package/src/domain.js
CHANGED
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
const EventEmitter = require("events");
|
|
7
|
-
const {
|
|
7
|
+
const {
|
|
8
|
+
executeObjectFunction,
|
|
9
|
+
objHas,
|
|
10
|
+
firstLetterToUpper,
|
|
11
|
+
} = require("./common");
|
|
8
12
|
const { error } = require("not-log")(module, "domain");
|
|
9
13
|
const Env = require("./env");
|
|
10
14
|
const notModule = require("./manifest/module"),
|
|
@@ -268,17 +272,12 @@ class notDomain extends EventEmitter {
|
|
|
268
272
|
/**
|
|
269
273
|
* Execute method in modules
|
|
270
274
|
* @param {string} methodName name of the method to execute
|
|
275
|
+
* @param {Object} params params to pass to method
|
|
271
276
|
**/
|
|
272
|
-
async execInModules(methodName) {
|
|
277
|
+
async execInModules(methodName, params) {
|
|
273
278
|
for (let mod of Object.values(this.#modules)) {
|
|
274
279
|
try {
|
|
275
|
-
|
|
276
|
-
if (isAsync(mod.exec)) {
|
|
277
|
-
await mod.exec(methodName);
|
|
278
|
-
} else {
|
|
279
|
-
mod.exec(methodName);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
280
|
+
await executeObjectFunction(mod, "exec", [params]);
|
|
282
281
|
} catch (e) {
|
|
283
282
|
this.report(e);
|
|
284
283
|
}
|
package/src/headers.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const notStyler = require("./styler");
|
|
2
|
+
|
|
3
|
+
const DEFAULT_STYLER = (req, res) => {
|
|
4
|
+
res.set("X-Frame-Options", "sameorigin");
|
|
5
|
+
res.set("X-Content-Type-Options", "nosniff");
|
|
6
|
+
res.set("Content-Security-Policy", "frame-ancestors 'self'");
|
|
7
|
+
res.set("X-XSS-Protection", "1; mode=block");
|
|
8
|
+
res.set("Referrer-Policy", "strict-origin");
|
|
9
|
+
res.set("Permissions-Policy", "camera=(), geolocation=(), microphone=()");
|
|
10
|
+
res.set("Cache-Control", "max-age=31536000");
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
class notHeadersStyler extends notStyler {}
|
|
14
|
+
|
|
15
|
+
notHeadersStyler.setDefault(DEFAULT_STYLER);
|
|
16
|
+
|
|
17
|
+
module.exports = notHeadersStyler;
|
package/src/identity/identity.js
CHANGED