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
package/src/init/index.js
CHANGED
package/src/init/lib/app.js
CHANGED
|
@@ -5,6 +5,8 @@ const logger = require("not-log");
|
|
|
5
5
|
const log = logger(module, "not-node//init//app");
|
|
6
6
|
const { notErrorReporter } = require("not-error");
|
|
7
7
|
|
|
8
|
+
const CONST_CORE_PATH = path.join(__dirname, "../../core");
|
|
9
|
+
|
|
8
10
|
module.exports = class InitApp {
|
|
9
11
|
static AppConstructor = notAppConstructor;
|
|
10
12
|
static ReporterConstructor = notErrorReporter;
|
|
@@ -35,7 +37,7 @@ module.exports = class InitApp {
|
|
|
35
37
|
|
|
36
38
|
static async initCore({ config, options, master, emit }) {
|
|
37
39
|
await emit("app.initCore.pre", { config, options, master });
|
|
38
|
-
master.getApp().importModuleFrom(
|
|
40
|
+
master.getApp().importModuleFrom(CONST_CORE_PATH);
|
|
39
41
|
await emit("app.initCore.post", { config, options, master });
|
|
40
42
|
}
|
|
41
43
|
|
|
@@ -44,12 +46,8 @@ module.exports = class InitApp {
|
|
|
44
46
|
master.getApp().importModulesFrom(config.get("modulesPath"));
|
|
45
47
|
if (Array.isArray(config.get("importModulesFromNPM"))) {
|
|
46
48
|
config.get("importModulesFromNPM").forEach((modName) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
.importModuleFrom(
|
|
50
|
-
path.join(config.get("npmPath"), modName),
|
|
51
|
-
modName
|
|
52
|
-
);
|
|
49
|
+
const modPath = path.join(config.get("npmPath"), modName);
|
|
50
|
+
master.getApp().importModuleFrom(modPath, modName);
|
|
53
51
|
});
|
|
54
52
|
}
|
|
55
53
|
await emit("app.importModules.post", { config, options, master });
|
package/src/init/lib/modules.js
CHANGED
package/src/init/lib/routes.js
CHANGED
|
@@ -61,6 +61,7 @@ module.exports = class InitRoutes {
|
|
|
61
61
|
log.info("Setting up routes...");
|
|
62
62
|
master.getApp().expose(master.getServer());
|
|
63
63
|
require(options.routesPath)(master.getServer(), master.getApp());
|
|
64
|
+
|
|
64
65
|
master.getServer().use(serveStatic(config.get("staticPath")));
|
|
65
66
|
master.getServer().use(options.indexRoute);
|
|
66
67
|
master.getServer().use(
|
package/src/manifest/module.js
CHANGED
|
@@ -6,7 +6,7 @@ const fs = require("fs"),
|
|
|
6
6
|
notManifest = require("./manifest.js"),
|
|
7
7
|
notModuleRegistrator = require("./registrator"),
|
|
8
8
|
notModuleInitializator = require("./initializator"),
|
|
9
|
-
{ objHas, mapBind,
|
|
9
|
+
{ objHas, mapBind, executeObjectFunction } = require("../common");
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Standart splitter of module resources paths
|
|
@@ -180,31 +180,17 @@ class notModule {
|
|
|
180
180
|
this.manifest = new notManifest(expressApp, this.notApp, moduleName);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
async exec(methodName) {
|
|
183
|
+
async exec(methodName, params) {
|
|
184
184
|
if (!this.module) {
|
|
185
185
|
log.error(
|
|
186
186
|
`Cant exec ${methodName} in module ${this.path}, module not loaded`
|
|
187
187
|
);
|
|
188
188
|
return false;
|
|
189
189
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
)
|
|
194
|
-
try {
|
|
195
|
-
if (isAsync(this.module[methodName])) {
|
|
196
|
-
await this.module[methodName](this.notApp);
|
|
197
|
-
} else {
|
|
198
|
-
this.module[methodName](this.notApp);
|
|
199
|
-
}
|
|
200
|
-
return true;
|
|
201
|
-
} catch (e) {
|
|
202
|
-
log.error(e);
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
} else {
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
190
|
+
await executeObjectFunction(this.module, methodName, [
|
|
191
|
+
this.notApp,
|
|
192
|
+
params,
|
|
193
|
+
]);
|
|
208
194
|
}
|
|
209
195
|
|
|
210
196
|
getStatus() {
|
package/src/metas.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const Auth = require("./auth"),
|
|
2
|
+
Env = require("./env"),
|
|
3
|
+
notStyler = require("./styler"),
|
|
4
|
+
config = require("not-config").createReader();
|
|
5
|
+
|
|
6
|
+
function getRole(req) {
|
|
7
|
+
if (Auth.isUser(req) && req.user) {
|
|
8
|
+
return req.user.getPrimaryRole(Env.getEnv("rolesPriority"));
|
|
9
|
+
} else {
|
|
10
|
+
return Auth.DEFAULT_USER_ROLE_FOR_GUEST;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const DEFAULT_STYLER = (req, res) => {
|
|
15
|
+
const role = getRole(req);
|
|
16
|
+
const host = config.get("fullServerName");
|
|
17
|
+
const canonical = host + req.originalUrl;
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
title: res?.options?.APP_TITLE,
|
|
21
|
+
desription: res?.options?.APP_DESCRIPTION,
|
|
22
|
+
canonical,
|
|
23
|
+
rand: Math.random(),
|
|
24
|
+
host,
|
|
25
|
+
role,
|
|
26
|
+
authenticated: role !== Auth.DEFAULT_USER_ROLE_FOR_GUEST,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
class notMetasStyler extends notStyler {}
|
|
31
|
+
|
|
32
|
+
notMetasStyler.setDefault(DEFAULT_STYLER);
|
|
33
|
+
|
|
34
|
+
module.exports = notMetasStyler;
|
package/src/styler.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const DEFAULT_STYLER = () => {
|
|
2
|
+
return {};
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
module.exports = class notStyler {
|
|
6
|
+
static #stylers = {};
|
|
7
|
+
static #defaultStyler = DEFAULT_STYLER;
|
|
8
|
+
|
|
9
|
+
static get(stylerName) {
|
|
10
|
+
if (
|
|
11
|
+
typeof stylerName !== "undefined" &&
|
|
12
|
+
Object.hasOwn(this.#stylers, stylerName)
|
|
13
|
+
) {
|
|
14
|
+
return this.#stylers[stylerName];
|
|
15
|
+
} else {
|
|
16
|
+
return this.#defaultStyler;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static set(stylerName, func) {
|
|
21
|
+
if (typeof stylerName === "string") {
|
|
22
|
+
this.#stylers[stylerName] = func;
|
|
23
|
+
} else {
|
|
24
|
+
throw new Error("Styler name should be a string");
|
|
25
|
+
}
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static setDefault(func) {
|
|
30
|
+
this.#defaultStyler = func;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static resetDefault() {
|
|
35
|
+
this.#defaultStyler = DEFAULT_STYLER;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
app: {
|
|
3
|
+
content: {
|
|
4
|
+
front: {
|
|
5
|
+
content: "front",
|
|
6
|
+
},
|
|
7
|
+
server: {
|
|
8
|
+
content: "server",
|
|
9
|
+
},
|
|
10
|
+
static: {
|
|
11
|
+
content: "static",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
bin: {
|
|
16
|
+
content: {
|
|
17
|
+
"build.sh": "app/build.sh",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
"project.manifest.json": {
|
|
21
|
+
tmpl: "app/project.manifest.ejs",
|
|
22
|
+
args: ["AppName", "roles", "modules"],
|
|
23
|
+
},
|
|
24
|
+
"package.json": {
|
|
25
|
+
tmpl: "app/package.ejs",
|
|
26
|
+
args: ["AppName", "appName", "AppDescription"],
|
|
27
|
+
},
|
|
28
|
+
".babelrc": "app/.babelrc",
|
|
29
|
+
".eslintignore": "app/.eslintignore",
|
|
30
|
+
".eslintrc.json": "app/.eslintrc.json",
|
|
31
|
+
".gitignore": "app/.gitignore",
|
|
32
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
common: {
|
|
3
|
+
content: {
|
|
4
|
+
"index.js": {
|
|
5
|
+
tmpl: "module.front/common/index.ejs",
|
|
6
|
+
args: ["modules", "AppName"],
|
|
7
|
+
},
|
|
8
|
+
"ncInit.js": {
|
|
9
|
+
tmpl: "module.front/common/ncInit.ejs",
|
|
10
|
+
args: ["modules", "AppName"],
|
|
11
|
+
},
|
|
12
|
+
"ws.client.main.js": {
|
|
13
|
+
tmpl: "module.front/common/ws.client.main.ejs",
|
|
14
|
+
ifModules: ["not-ws"],
|
|
15
|
+
args: ["modules", "AppName"],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
const EMPTY_CONFIG = "app/config/other.ejs";
|
|
2
|
+
export default {
|
|
3
|
+
config: {
|
|
4
|
+
content: {
|
|
5
|
+
"common.json": {
|
|
6
|
+
tmpl: "app/config/common.ejs",
|
|
7
|
+
args: [
|
|
8
|
+
"hostname",
|
|
9
|
+
"port",
|
|
10
|
+
"cors",
|
|
11
|
+
"ssl",
|
|
12
|
+
"secret",
|
|
13
|
+
"session",
|
|
14
|
+
"db",
|
|
15
|
+
"modules",
|
|
16
|
+
"filter",
|
|
17
|
+
"roles",
|
|
18
|
+
"rolesSecondary",
|
|
19
|
+
"user",
|
|
20
|
+
"ws",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
"development.json": {
|
|
24
|
+
tmpl: EMPTY_CONFIG,
|
|
25
|
+
args: ["hostname"],
|
|
26
|
+
options: {
|
|
27
|
+
ENV: "development",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
"stage.json": {
|
|
31
|
+
tmpl: EMPTY_CONFIG,
|
|
32
|
+
args: ["hostname"],
|
|
33
|
+
options: {
|
|
34
|
+
ENV: "stage",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
"production.json": {
|
|
38
|
+
tmpl: EMPTY_CONFIG,
|
|
39
|
+
args: ["hostname"],
|
|
40
|
+
options: {
|
|
41
|
+
ENV: "production",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
modules: {},
|
|
47
|
+
routes: {
|
|
48
|
+
content: {
|
|
49
|
+
"index.js": {
|
|
50
|
+
tmpl: "app/routes/index.ejs",
|
|
51
|
+
args: ["AppName", "AppDescription", "modules", "roles"],
|
|
52
|
+
},
|
|
53
|
+
"site.js": {
|
|
54
|
+
tmpl: "app/routes/site.ejs",
|
|
55
|
+
args: ["AppName", "AppDescription", "modules", "roles"],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
views: {
|
|
60
|
+
content: {
|
|
61
|
+
admin: {
|
|
62
|
+
content: {
|
|
63
|
+
"foot.pug": {
|
|
64
|
+
tmpl: "app/views/admin/foot.ejs",
|
|
65
|
+
},
|
|
66
|
+
"head.pug": {
|
|
67
|
+
tmpl: "app/views/admin/head.ejs",
|
|
68
|
+
},
|
|
69
|
+
"menu.pug": {
|
|
70
|
+
tmpl: "app/views/admin/menu.ejs",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
parts: {
|
|
75
|
+
content: {
|
|
76
|
+
"overview.pug": {
|
|
77
|
+
tmpl: "app/views/parts/overview.ejs",
|
|
78
|
+
},
|
|
79
|
+
"menu.pug": {
|
|
80
|
+
tmpl: "app/views/parts/menu.ejs",
|
|
81
|
+
},
|
|
82
|
+
"header.pug": {
|
|
83
|
+
tmpl: "app/views/parts/header.ejs",
|
|
84
|
+
},
|
|
85
|
+
"header.ios.pug": {
|
|
86
|
+
tmpl: "app/views/parts/header.ios.ejs",
|
|
87
|
+
},
|
|
88
|
+
"header.android.pug": {
|
|
89
|
+
tmpl: "app/views/parts/header.android.ejs",
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
"admin.pug": {
|
|
94
|
+
tmpl: "app/views/admin.ejs",
|
|
95
|
+
},
|
|
96
|
+
"dashboard.pug": {
|
|
97
|
+
tmpl: "app/views/dashboard.ejs",
|
|
98
|
+
},
|
|
99
|
+
"index.pug": {
|
|
100
|
+
tmpl: "app/views/index.ejs",
|
|
101
|
+
args: ["hostname"],
|
|
102
|
+
options: {
|
|
103
|
+
ENV: "production",
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
ws: {
|
|
109
|
+
content: {
|
|
110
|
+
"auth.js": {
|
|
111
|
+
tmpl: "app/ws/auth.ejs",
|
|
112
|
+
},
|
|
113
|
+
"index.js": {
|
|
114
|
+
tmpl: "app/ws/index.ejs",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
ifModules: ["not-ws"],
|
|
118
|
+
},
|
|
119
|
+
"app.js": {
|
|
120
|
+
tmpl: "app/app.ejs",
|
|
121
|
+
args: [],
|
|
122
|
+
},
|
|
123
|
+
"index.js": {
|
|
124
|
+
tmpl: "app/index.ejs",
|
|
125
|
+
args: [],
|
|
126
|
+
},
|
|
127
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"parserOptions": {
|
|
3
|
+
"ecmaVersion": 10,
|
|
4
|
+
"sourceType": "module"
|
|
5
|
+
},
|
|
6
|
+
"env": {
|
|
7
|
+
"browser": true,
|
|
8
|
+
"es6": true,
|
|
9
|
+
"node": true,
|
|
10
|
+
"mongo": true,
|
|
11
|
+
"mocha": true
|
|
12
|
+
},
|
|
13
|
+
"globals": {
|
|
14
|
+
"ENV": true
|
|
15
|
+
},
|
|
16
|
+
"extends": "eslint:recommended",
|
|
17
|
+
"rules": {
|
|
18
|
+
"indent": "error",
|
|
19
|
+
"linebreak-style": ["error", "unix"],
|
|
20
|
+
"semi": ["error", "always"],
|
|
21
|
+
"no-useless-escape": [0]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const notNode = require("not-node");
|
|
2
|
+
|
|
3
|
+
const Init = require("not-node").Init,
|
|
4
|
+
path = require("path"),
|
|
5
|
+
manifest = require("./../../project.manifest.json");
|
|
6
|
+
|
|
7
|
+
module.exports = () => {
|
|
8
|
+
const options = {
|
|
9
|
+
pathToApp: path.join(__dirname),
|
|
10
|
+
pathToNPM: path.join(__dirname, "../../node_modules"),
|
|
11
|
+
routesPath: path.join(__dirname, "./routes"),
|
|
12
|
+
indexRoute: require("./routes/site.js").index,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const additional = {
|
|
16
|
+
pre({ initSequence }) {
|
|
17
|
+
initSequence.remove("InitMonitoring");
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
Init.run({ options, manifest, additional });
|
|
22
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
echo 'building for' $ENV 'environment'
|
|
3
|
+
rm -rf ./app/front/build/${TARGET_ROLE}.min.js
|
|
4
|
+
rm -rf ./app/front/build/${TARGET_ROLE}.js
|
|
5
|
+
rm -rf ./app/front/build/${TARGET_ROLE}.css
|
|
6
|
+
NODE_ENV=$ENV ./node_modules/.bin/eslint ./src/controllers
|
|
7
|
+
NODE_ENV=$ENV ./node_modules/.bin/rollup -c ./rollup/${TARGET_ROLE}.js --environment ENV:$ENV
|
|
8
|
+
NODE_ENV=$ENV ./node_modules/.bin/terser --compress --mangle -- build/${TARGET_ROLE}.js > ./build/${TARGET_ROLE}.min.js
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
{
|
|
2
|
+
"port": <%- port %>,
|
|
3
|
+
"host": "<%- hostname.development %>",
|
|
4
|
+
"cors": [<%- cors.map(entry => `"${entry}"`).join(',') %>],
|
|
5
|
+
"template": {
|
|
6
|
+
"engine": "pug",
|
|
7
|
+
"views": "views",
|
|
8
|
+
"partialsDir": "partials",
|
|
9
|
+
"partials": {}
|
|
10
|
+
},
|
|
11
|
+
<% if (db) { %>
|
|
12
|
+
"db": {
|
|
13
|
+
<% if (db.mongoose) {%>
|
|
14
|
+
"mongoose": {
|
|
15
|
+
"uri": "mongodb://<%- db.mongoose.hostname %>/<%- db.mongoose.db %>?authSource=<%- db.mongoose.authSource %>",
|
|
16
|
+
"options": {
|
|
17
|
+
"useNewUrlParser": true,
|
|
18
|
+
"useUnifiedTopology": true,
|
|
19
|
+
"db": "<%- db.mongoose.db %>",
|
|
20
|
+
"host": "<%- db.mongoose.hostname %>",
|
|
21
|
+
"user": "<%- db.mongoose.user %>",
|
|
22
|
+
"pass": "<%- db.mongoose.pass %>",
|
|
23
|
+
"autoIndex": false
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
<% } %>
|
|
27
|
+
<% if (db.redis) { %>
|
|
28
|
+
"redis": {},
|
|
29
|
+
<% } %>
|
|
30
|
+
<% if (db.ioredis) { %>
|
|
31
|
+
"ioredis": {
|
|
32
|
+
"enableOfflineQueue": false
|
|
33
|
+
}
|
|
34
|
+
<% } %>
|
|
35
|
+
},
|
|
36
|
+
<% } %>
|
|
37
|
+
<% if (session){ %>
|
|
38
|
+
"session": {
|
|
39
|
+
"driver": "<%- session.driver %>",
|
|
40
|
+
"secret": "<%- session.secret %>",
|
|
41
|
+
"cookie": {
|
|
42
|
+
"maxAge": <%- session.ttl %>
|
|
43
|
+
},
|
|
44
|
+
"key": "<%- session.key %>"
|
|
45
|
+
},
|
|
46
|
+
<% } %>
|
|
47
|
+
<% if (ssl) { %>
|
|
48
|
+
"ssl": {
|
|
49
|
+
"enabled": true,
|
|
50
|
+
"keys": {
|
|
51
|
+
"private": "<%- ssl.private %>",
|
|
52
|
+
"fullchain": "<%- ssl.fullchain %>",
|
|
53
|
+
"chain": "<%- ssl.chain %>"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
<% } %>
|
|
57
|
+
"path": {
|
|
58
|
+
"static": "../static",
|
|
59
|
+
"app": "/client",
|
|
60
|
+
"dbDumps": "../../../db.dumps",
|
|
61
|
+
"front": "../front/build",
|
|
62
|
+
"ws": "./ws"
|
|
63
|
+
},
|
|
64
|
+
"defaultUserRole": "user",
|
|
65
|
+
"modules": {
|
|
66
|
+
<% if (modules.includes('not-ws') && ws) { %>
|
|
67
|
+
"ws": {
|
|
68
|
+
"servers": {
|
|
69
|
+
"main": {
|
|
70
|
+
"connection": {
|
|
71
|
+
"port": <%- ws.port %>,
|
|
72
|
+
"secure": <%= ws.secure %>,
|
|
73
|
+
"secret": "<%- secret %>"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
<% } %>
|
|
79
|
+
<% if (modules.includes('not-user') && user){ %>
|
|
80
|
+
"user": {
|
|
81
|
+
"errors":{
|
|
82
|
+
"noUserData": false,
|
|
83
|
+
"noUserWithId": false
|
|
84
|
+
},
|
|
85
|
+
"debug":{
|
|
86
|
+
"loaded": false
|
|
87
|
+
},
|
|
88
|
+
"tokenTTL": <%= user.tokenTTL %>,
|
|
89
|
+
"secret": "<%- secret %>",
|
|
90
|
+
"roles": {
|
|
91
|
+
"primary": [<%- roles.map(entry => `"${entry}"`).join(",") %>],
|
|
92
|
+
"secondary": [<%- rolesSecondary.map(entry => `"${entry}"`).join(",") %>]
|
|
93
|
+
},
|
|
94
|
+
"restrict": {
|
|
95
|
+
"registration": <%= user?.restrict?.registration ?? false %>
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
<% } %>
|
|
99
|
+
<% if (modules.includes('not-filter') && filter){ %>
|
|
100
|
+
"filter": {
|
|
101
|
+
"size": <%= filter?.size ?? 15 %>,
|
|
102
|
+
"default": {
|
|
103
|
+
"filter": {},
|
|
104
|
+
"sorter": {
|
|
105
|
+
"_id": 1
|
|
106
|
+
},
|
|
107
|
+
"pager": {
|
|
108
|
+
"size": <%= filter?.pager?.size ?? 15 %>,
|
|
109
|
+
"skip": 0,
|
|
110
|
+
"page": 0
|
|
111
|
+
},
|
|
112
|
+
"search": ""
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
<% } %>
|
|
116
|
+
<% if (modules.includes('not-filter')){ %>
|
|
117
|
+
"rateLimiter": {
|
|
118
|
+
"keyPrefix": "rateLimiterMiddleware",
|
|
119
|
+
"points": 500,
|
|
120
|
+
"duration": 1
|
|
121
|
+
}
|
|
122
|
+
<% } %>
|
|
123
|
+
},
|
|
124
|
+
"middleware": {
|
|
125
|
+
<%- modules.map(entry => `"${entry}": {}`).join(',') %>
|
|
126
|
+
},
|
|
127
|
+
"importModulesFromNPM": [
|
|
128
|
+
<%- modules.map(entry => `"${entry}"`).join(',') %>
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hostname":"<%- hostname[__options__.ENV] %>",
|
|
3
|
+
"CSP": {
|
|
4
|
+
"connect": [
|
|
5
|
+
"'self'",
|
|
6
|
+
"*",
|
|
7
|
+
"wss:",
|
|
8
|
+
"https:",
|
|
9
|
+
"'unsafe-inline'"
|
|
10
|
+
],
|
|
11
|
+
"default": [
|
|
12
|
+
"'self'",
|
|
13
|
+
"*",
|
|
14
|
+
"wss:",
|
|
15
|
+
"https:",
|
|
16
|
+
"'unsafe-inline'"
|
|
17
|
+
],
|
|
18
|
+
"img": [
|
|
19
|
+
"'self'",
|
|
20
|
+
"data:"
|
|
21
|
+
],
|
|
22
|
+
"script": [
|
|
23
|
+
"'self'",
|
|
24
|
+
"'unsafe-eval'",
|
|
25
|
+
"'unsafe-inline'"
|
|
26
|
+
],
|
|
27
|
+
"style": [
|
|
28
|
+
"'self'",
|
|
29
|
+
"'unsafe-inline'",
|
|
30
|
+
"'unsafe-eval'"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"apps": [{
|
|
3
|
+
"name": "<%- AppName %>",
|
|
4
|
+
"script": "./<%- AppDirName %>/app/server/index.js",
|
|
5
|
+
"node_args": [
|
|
6
|
+
<% nodeArgs.forEach(function(nodeArg, index){ %>
|
|
7
|
+
"<%- nodeArg %>"<%- (nodeArgs.length - 1 > index)?',':'' %>
|
|
8
|
+
<% }); %>
|
|
9
|
+
],
|
|
10
|
+
"watch": <%- watch?'true':'false' %>,
|
|
11
|
+
"ignore_watch": [
|
|
12
|
+
<% ignoreWatchList.forEach(function(ignorePath, index){ %>
|
|
13
|
+
"<%- ignorePath %>"<%- (ignoreWatchList.length - 1 > index)?',':'' %>
|
|
14
|
+
<% }); %>
|
|
15
|
+
],
|
|
16
|
+
"exec_mode": "fork",
|
|
17
|
+
"env": {
|
|
18
|
+
<% envs.forEach(function(env, index){ %>
|
|
19
|
+
"<%- env.name %>": "<%- env.value %>"<%- (envs.length - 1 > index)?',':'' %>
|
|
20
|
+
<% }); %>
|
|
21
|
+
}
|
|
22
|
+
}]
|
|
23
|
+
}
|