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,36 @@
|
|
|
1
|
+
const
|
|
2
|
+
notNode = require('not-node'),
|
|
3
|
+
Auth = require('not-node').Auth,
|
|
4
|
+
siteRouter = require('./site');
|
|
5
|
+
|
|
6
|
+
module.exports = (web) => {
|
|
7
|
+
|
|
8
|
+
web.get('/api/manifest', function(req, res) {
|
|
9
|
+
notNode.notHeadersStyler.get()(req,res);
|
|
10
|
+
res.status(200).json(notNode.Application.getManifest(req));
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
web.get('/', (req, res, next) => {
|
|
15
|
+
if (Auth.isUser(req)) {
|
|
16
|
+
res.redirect('/dashboard');
|
|
17
|
+
}else{
|
|
18
|
+
next();
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
siteRouter.index
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
web.get('/dashboard*',
|
|
26
|
+
(req, res, next) => {
|
|
27
|
+
if (Auth.isUser(req)) {
|
|
28
|
+
next();
|
|
29
|
+
} else {
|
|
30
|
+
res.redirect('/login');
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
siteRouter.dashboard
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const
|
|
2
|
+
notError = require('not-error').notError,
|
|
3
|
+
notNode = require('not-node');
|
|
4
|
+
|
|
5
|
+
const METAS_OVERRIDES = {
|
|
6
|
+
title: "notNodeApplication",
|
|
7
|
+
desription: "notNodeApplication",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
function getMetas(req, res){
|
|
11
|
+
const styler = notNode.notMetasStyler.get();
|
|
12
|
+
return {...styler(req, res), ...METAS_OVERRIDES};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports.index = function (req, res, next) {
|
|
16
|
+
notNode.Application.logger.debug('index '+ notNode.Auth.getIP(req) + ' : ' + req.originalUrl);
|
|
17
|
+
if (req.originalUrl.indexOf('/api/') == 0) {
|
|
18
|
+
return next();
|
|
19
|
+
}
|
|
20
|
+
notNode.notHeadersStyler.get()(req, res)
|
|
21
|
+
const layout = 'index';
|
|
22
|
+
try {
|
|
23
|
+
const metas = getMetas(req, res);
|
|
24
|
+
res.render(layout, metas, (err, html) => {
|
|
25
|
+
if (err) {
|
|
26
|
+
notNode.Application.logger.error(['rendering error', err]);
|
|
27
|
+
notNode.Application.report(new notError('rendering error', {
|
|
28
|
+
...metas,
|
|
29
|
+
session: req.session.id
|
|
30
|
+
}, err));
|
|
31
|
+
res.status(500).end();
|
|
32
|
+
} else {
|
|
33
|
+
res.status(200).send(html).end();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
} catch (e) {
|
|
37
|
+
let err = new notError('Index page generation error', {}, e);
|
|
38
|
+
notNode.Application.logger.error(err);
|
|
39
|
+
notNode.Application.report(err);
|
|
40
|
+
res.status(500).end();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
module.exports.dashboard = (req, res, next) => {
|
|
45
|
+
try {
|
|
46
|
+
notNode.Application.logger.debug(notNode.Auth.getIP(req), 'dashboard');
|
|
47
|
+
if (req.originalUrl.indexOf('/api/') == 0) {
|
|
48
|
+
return next();
|
|
49
|
+
}
|
|
50
|
+
const layout = 'dashboard';
|
|
51
|
+
const metas = getMetas(req, res);
|
|
52
|
+
res.render(layout, metas, (err, html) => {
|
|
53
|
+
if (err) {
|
|
54
|
+
notNode.Application.logger.error(['rendering error', err]);
|
|
55
|
+
notNode.Application.report(new notError('rendering error', {
|
|
56
|
+
...metas,
|
|
57
|
+
session: req.session.id
|
|
58
|
+
}, err));
|
|
59
|
+
res.status(500).end();
|
|
60
|
+
} else {
|
|
61
|
+
res.status(200).send(html).end();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
} catch (e) {
|
|
66
|
+
let err = new notError('Dashboard page generation error', {}, e);
|
|
67
|
+
notNode.Application.logger.error(err);
|
|
68
|
+
notNode.Application.report(err);
|
|
69
|
+
res.status(500).end();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
script(src=host+"/front/root.js")
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
meta(charset="utf-8")
|
|
2
|
+
meta(http-equiv="x-ua-compatible" content="ie=edge")
|
|
3
|
+
meta(name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no")
|
|
4
|
+
link(rel="manifest" href="/site.webmanifest")
|
|
5
|
+
link(rel="apple-touch-icon" href="/icon.png")
|
|
6
|
+
link(rel="stylesheet" href="css/style.css")
|
|
7
|
+
link(rel="stylesheet" href=host+"/front/root.css")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
doctype html
|
|
2
|
+
html.no-js(lang="ru-RU")
|
|
3
|
+
head
|
|
4
|
+
title Administration system
|
|
5
|
+
meta(name="keywords" content="")
|
|
6
|
+
meta(name="description" content="")
|
|
7
|
+
meta(name="author" content="")
|
|
8
|
+
include admin/head.pug
|
|
9
|
+
body
|
|
10
|
+
nav(class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0")
|
|
11
|
+
a(class="navbar-brand col-sm-3 col-md-2 mr-0" href="/dashboard")
|
|
12
|
+
ul(class="navbar-nav px-3")
|
|
13
|
+
li(class="nav-item text-nowrap")
|
|
14
|
+
a(class="nav-link" n-href="/logout") Logout
|
|
15
|
+
div.container-fluid
|
|
16
|
+
div.row
|
|
17
|
+
include admin/menu.pug
|
|
18
|
+
main(role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4 main-container")
|
|
19
|
+
include admin/foot.pug
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
doctype html
|
|
2
|
+
html.no-js(lang="")
|
|
3
|
+
head
|
|
4
|
+
meta(charset="utf-8")
|
|
5
|
+
meta(http-equiv="x-ua-compatible" content="ie=edge")
|
|
6
|
+
title= title
|
|
7
|
+
meta(name="description" content=description)
|
|
8
|
+
meta(name="viewport" content="width=device-width, initial-scale=1")
|
|
9
|
+
link(rel="apple-touch-icon" href="apple-touch-icon.png")
|
|
10
|
+
link(rel="stylesheet" href=host+"/assets/font-awasome-5.13.1-all.min.css")
|
|
11
|
+
link(rel="stylesheet" href=host+"/front/"+role+".css")
|
|
12
|
+
body
|
|
13
|
+
nav(id="top-menu" class="navbar is-success" role="navigation" aria-label="dropdown navigation")
|
|
14
|
+
aside(class="menu main-menu" id="side-menu")
|
|
15
|
+
main
|
|
16
|
+
section(class="section main-container")
|
|
17
|
+
footer(class="footer")
|
|
18
|
+
div(class="content has-text-centered")
|
|
19
|
+
p footer
|
|
20
|
+
script(src="/front/"+role+".js")
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
doctype html
|
|
2
|
+
html.no-js(lang="")
|
|
3
|
+
head
|
|
4
|
+
|
|
5
|
+
include ./parts/header.pug
|
|
6
|
+
|
|
7
|
+
body
|
|
8
|
+
section(class="hero is-success is-fullheight")
|
|
9
|
+
include ./parts/menu.pug
|
|
10
|
+
div(class="hero-body")
|
|
11
|
+
div(class="container has-text-centered")
|
|
12
|
+
h1(class="title") Hello world
|
|
13
|
+
h2(class="subtitle") and so it begins
|
|
14
|
+
include ./parts/overview.pug
|
|
15
|
+
script(src=host+"/front/"+role+".js")
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
<!-- Android -->
|
|
3
|
+
meta(name="theme-color" content="#48c774")
|
|
4
|
+
meta(name="color-scheme" content="light")
|
|
5
|
+
meta(name="mobile-web-app-capable" content="yes")
|
|
6
|
+
link(rel="stylesheet" href=host+"/front/"+role+".css")
|
|
7
|
+
link(rel="stylesheet" href=host+"/assets/font-awesome.min.css")
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
meta(charset="utf-8")
|
|
2
|
+
meta(http-equiv="x-ua-compatible" content="ie=edge")
|
|
3
|
+
meta(name="viewport" content="width=device-width, initial-scale=1")
|
|
4
|
+
title= title
|
|
5
|
+
link(rel="icon" type="image/png" href="/img/icons/icon-64.png")
|
|
6
|
+
link(rel="manifest" href="/manifest.json")
|
|
7
|
+
link(rel="canonical" href=canonical)
|
|
8
|
+
|
|
9
|
+
meta(name="description" content=description)
|
|
10
|
+
meta(name="application-name" content=title)
|
|
11
|
+
meta(name="author" content="" )
|
|
12
|
+
meta(name="referrer" content="strict-origin")
|
|
13
|
+
meta(itemprop="name" content=title)
|
|
14
|
+
meta(itemprop="description" content=description)
|
|
15
|
+
meta(itemprop="image" content="./img/icons/icon-128.png")
|
|
16
|
+
|
|
17
|
+
include ./header.ios.pug
|
|
18
|
+
include ./header.android.pug
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nav(class="navbar is-success" role="navigation" aria-label="dropdown navigation" id="top-menu")
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const Log = require("not-log")(module, "WS::Auth");
|
|
2
|
+
const notNode = require("not-node");
|
|
3
|
+
const ObjectId = require("mongoose").Types.ObjectId;
|
|
4
|
+
|
|
5
|
+
function isRoot(token) {
|
|
6
|
+
return token.role ? token.role.indexOf("root") > -1 : false;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function isAuth(_id) {
|
|
10
|
+
try {
|
|
11
|
+
return !!ObjectId(_id);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
module.exports = ({ serviceData, cred }) => {
|
|
18
|
+
//Log.log(serviceData, cred);
|
|
19
|
+
const [model, action] = serviceData.name.split("//");
|
|
20
|
+
//Log.log(model, action);
|
|
21
|
+
let user = {
|
|
22
|
+
auth: isAuth(cred._id),
|
|
23
|
+
role: cred.role,
|
|
24
|
+
root: isRoot(cred),
|
|
25
|
+
username: cred.username,
|
|
26
|
+
email: cred.email,
|
|
27
|
+
emailConfirmed: cred.emailConfirmed,
|
|
28
|
+
};
|
|
29
|
+
//Log.log(user);
|
|
30
|
+
let actionManifest = notNode.Application.getActionManifestForUser(
|
|
31
|
+
model,
|
|
32
|
+
action,
|
|
33
|
+
user
|
|
34
|
+
);
|
|
35
|
+
Log.log(model, action, user.username, user.role, !!actionManifest);
|
|
36
|
+
if (actionManifest) {
|
|
37
|
+
return true;
|
|
38
|
+
} else {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const jwt = require("jsonwebtoken"),
|
|
2
|
+
config = require("not-config").createReader(),
|
|
3
|
+
log = require("not-log")(module, "WS"),
|
|
4
|
+
authRoute = require("./auth.js");
|
|
5
|
+
|
|
6
|
+
const { notWSMessenger } = require("not-ws");
|
|
7
|
+
const { notRequestError, notValidationError } = require("not-error");
|
|
8
|
+
|
|
9
|
+
const mainValidators = {
|
|
10
|
+
credentials(credentials, serviceData) {
|
|
11
|
+
try {
|
|
12
|
+
log.log(serviceData.type, serviceData.name);
|
|
13
|
+
let cred = jwt.verify(
|
|
14
|
+
credentials,
|
|
15
|
+
config.get("modules:user:secret")
|
|
16
|
+
);
|
|
17
|
+
if (cred) {
|
|
18
|
+
return authRoute({ serviceData, cred });
|
|
19
|
+
} else {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
} catch (e) {
|
|
23
|
+
log.error(e);
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function wrapError(data, serviceData, error) {
|
|
30
|
+
if (error instanceof notRequestError) {
|
|
31
|
+
return {
|
|
32
|
+
status: "error",
|
|
33
|
+
message: error.getResult().message,
|
|
34
|
+
errors: error.getResult().errors,
|
|
35
|
+
};
|
|
36
|
+
} else if (error instanceof notValidationError) {
|
|
37
|
+
return {
|
|
38
|
+
status: "error",
|
|
39
|
+
message: error.message,
|
|
40
|
+
errors: error.getFieldsErrors(),
|
|
41
|
+
};
|
|
42
|
+
} else {
|
|
43
|
+
return {
|
|
44
|
+
status: "error",
|
|
45
|
+
message: error.message,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function wrapOk(result) {
|
|
51
|
+
return {
|
|
52
|
+
status: "ok",
|
|
53
|
+
result,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
servers: {
|
|
59
|
+
main: {
|
|
60
|
+
logger: log,
|
|
61
|
+
jwt: {
|
|
62
|
+
key: config.get("modules:user:secret"),
|
|
63
|
+
},
|
|
64
|
+
getMessenger() {
|
|
65
|
+
return new notWSMessenger({
|
|
66
|
+
logger: log,
|
|
67
|
+
secure: true,
|
|
68
|
+
validateTypeAndName: false,
|
|
69
|
+
validators: mainValidators,
|
|
70
|
+
wrap: {
|
|
71
|
+
ok: wrapOk,
|
|
72
|
+
error: wrapError,
|
|
73
|
+
},
|
|
74
|
+
types: {
|
|
75
|
+
request: [],
|
|
76
|
+
response: [],
|
|
77
|
+
event: [],
|
|
78
|
+
__service: [],
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
@@ -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,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "not-node-application",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "notNodeApplication",
|
|
5
|
+
"main": "app.js",
|
|
6
|
+
"private": true,
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">14.9"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "./node_modules/.bin/mocha --reporter spec ./tests/**.js",
|
|
12
|
+
"lint": "./node_modules/.bin/eslint ./app/**/**.js ./app/server/**/**/**.js ./app/server/**/**/**/**.js ./app/server/**/**/**/**/**.js --fix",
|
|
13
|
+
"docs": "./node_modules/.bin/jsdoc -c jsdoc.json",
|
|
14
|
+
"cover": "nyc npm test",
|
|
15
|
+
"build:dev:guest:watch": "watch 'npm run build:dev:guest' ./app/front/src --interval=5",
|
|
16
|
+
"build": "./node_modules/.bin/not-builder --config='./project.manifest.json'",
|
|
17
|
+
"build:dev": "npm run development",
|
|
18
|
+
"build:dev:guest": "./node_modules/.bin/not-builder --config='./project.manifest.json' --role=guest --environment=development",
|
|
19
|
+
"build:dev:user": "./node_modules/.bin/not-builder --config='./project.manifest.json' --role=user --environment=development",
|
|
20
|
+
"build:dev:client": "./node_modules/.bin/not-builder --config='./project.manifest.json' --role=client --environment=development",
|
|
21
|
+
"build:dev:admin": "./node_modules/.bin/not-builder --config='./project.manifest.json' --role=admin --environment=development",
|
|
22
|
+
"build:dev:root": "./node_modules/.bin/not-builder --config='./project.manifest.json' --role=root --environment=development",
|
|
23
|
+
"archive": "./bin/archive.sh",
|
|
24
|
+
"production": "./node_modules/.bin/not-builder --config='./project.manifest.json' --environment=production",
|
|
25
|
+
"development": "./node_modules/.bin/not-builder --config='./project.manifest.json' --environment=development",
|
|
26
|
+
"stage": "./node_modules/.bin/not-builder --config='./project.manifest.json' --environment=stage",
|
|
27
|
+
"update": "ncu -u -x escape-string-regexp && npm i",
|
|
28
|
+
"urd:dev": "npm run update && npm run build:dev && pm2 restart not-node-application.dev"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"redis": "*",
|
|
32
|
+
"not-node": "*"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@babel/core": "^7.18.9",
|
|
36
|
+
"@babel/polyfill": "^7.12.1",
|
|
37
|
+
"@babel/preset-env": "^7.18.9",
|
|
38
|
+
"@babel/plugin-syntax-class-properties": "^7.12.13",
|
|
39
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
40
|
+
"@rollup/plugin-commonjs": "^22.0.1",
|
|
41
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
42
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
43
|
+
"babel-core": "*",
|
|
44
|
+
"babel-polyfill": "*",
|
|
45
|
+
"babel-preset-es2015-rollup": "*",
|
|
46
|
+
"babel-runtime": "*",
|
|
47
|
+
"chai": "^4.3.6",
|
|
48
|
+
"eslint": "^8.20.0",
|
|
49
|
+
"ink-docstrap": "^1.3.2",
|
|
50
|
+
"jsdoc": "^3.6.11",
|
|
51
|
+
"mocha": "^10.0.0",
|
|
52
|
+
"ndb": "^1.1.5",
|
|
53
|
+
"nyc": "^15.1.0",
|
|
54
|
+
"rollup": "^2.77.2",
|
|
55
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
56
|
+
"rollup-plugin-sass": "^1.2.13",
|
|
57
|
+
"rollup-plugin-svelte": "^7.1.0",
|
|
58
|
+
"rollup-plugin-eslint": "^7.0.0",
|
|
59
|
+
"rollup-plugin-filesize": "^9.1.2",
|
|
60
|
+
"rollup-plugin-sizes": "^1.0.4",
|
|
61
|
+
"rollup-watch": "*",
|
|
62
|
+
"should": "^13.2.3",
|
|
63
|
+
"svelte": "*",
|
|
64
|
+
"yargs": "^17.5.1"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "notNodeApplication",
|
|
3
|
+
"targets": {
|
|
4
|
+
"server": {
|
|
5
|
+
"name": "notNodeApplication",
|
|
6
|
+
"roles": ["root","admin","client","user","guest"],
|
|
7
|
+
"builder": "server",
|
|
8
|
+
"root": "app/front/",
|
|
9
|
+
"src": "app/front/",
|
|
10
|
+
"build": "app/front/build/",
|
|
11
|
+
"index": "app/front/index.!.js",
|
|
12
|
+
"rollup": "app/front/rollup.!.js",
|
|
13
|
+
"modules": {
|
|
14
|
+
"serverModulesDir": "app/server/modules",
|
|
15
|
+
"frontModulesDir": "app/front/src",
|
|
16
|
+
"npm": {
|
|
17
|
+
"not-options": {},
|
|
18
|
+
"not-filter": {},
|
|
19
|
+
"not-inform": {},
|
|
20
|
+
"not-inform-rule-tag": {},
|
|
21
|
+
"not-inform-sink-email": {},
|
|
22
|
+
"not-inform-sink-ws": {},
|
|
23
|
+
"not-key": {},
|
|
24
|
+
"not-ws": {},
|
|
25
|
+
"not-store": {},
|
|
26
|
+
"not-dbdump": {},
|
|
27
|
+
"not-user": {},
|
|
28
|
+
"not-error": {}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
package/src/app.js
CHANGED
|
@@ -72,12 +72,12 @@ class notApp extends notDomain {
|
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Exposes routes to ExpressJS application
|
|
75
|
-
* @param {object}
|
|
75
|
+
* @param {object} web ExpressJS application instance
|
|
76
76
|
**/
|
|
77
|
-
expose(
|
|
77
|
+
expose(web) {
|
|
78
78
|
this.forEachMod((modName, mod) => {
|
|
79
79
|
if (typeof mod.expose === "function") {
|
|
80
|
-
mod.expose(
|
|
80
|
+
mod.expose(web, modName);
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const DEFAULT_PRIMARY_ROLES_SET = ["root", "admin", "client", "user", "guest"];
|
|
2
|
+
export { DEFAULT_PRIMARY_ROLES_SET };
|
|
3
|
+
|
|
4
|
+
const DEFAULT_MODULES_SET = [
|
|
5
|
+
"not-options",
|
|
6
|
+
"not-filter",
|
|
7
|
+
"not-notification",
|
|
8
|
+
"not-locale",
|
|
9
|
+
"not-inform",
|
|
10
|
+
"not-inform-rule-tag",
|
|
11
|
+
"not-inform-sink-email",
|
|
12
|
+
"not-inform-sink-notification",
|
|
13
|
+
"not-inform-sink-ws",
|
|
14
|
+
"not-key",
|
|
15
|
+
"not-ws",
|
|
16
|
+
"not-store",
|
|
17
|
+
"not-dbdump",
|
|
18
|
+
"not-user",
|
|
19
|
+
"not-error",
|
|
20
|
+
];
|
|
21
|
+
export { DEFAULT_MODULES_SET };
|
|
22
|
+
|
|
23
|
+
const DEFAULT_MODULE_LAYERS = [
|
|
24
|
+
"fields",
|
|
25
|
+
"models",
|
|
26
|
+
"logics",
|
|
27
|
+
"routes",
|
|
28
|
+
"forms",
|
|
29
|
+
"controllers",
|
|
30
|
+
"locales",
|
|
31
|
+
];
|
|
32
|
+
export { DEFAULT_MODULE_LAYERS };
|
|
33
|
+
|
|
34
|
+
const DEFAULT_ENTITY_LAYERS = [
|
|
35
|
+
"forms",
|
|
36
|
+
"models",
|
|
37
|
+
"logics",
|
|
38
|
+
"routes",
|
|
39
|
+
"controllers",
|
|
40
|
+
];
|
|
41
|
+
export { DEFAULT_ENTITY_LAYERS };
|
|
42
|
+
|
|
43
|
+
const DEFAULT_MODULE_ACTIONS = [
|
|
44
|
+
"create",
|
|
45
|
+
"delete",
|
|
46
|
+
"get",
|
|
47
|
+
"getRaw",
|
|
48
|
+
"listAll",
|
|
49
|
+
"listAndCount",
|
|
50
|
+
"update",
|
|
51
|
+
];
|
|
52
|
+
export { DEFAULT_MODULE_ACTIONS };
|
|
53
|
+
|
|
54
|
+
const DEFAULT_MODULES_SET_ENABLED = [
|
|
55
|
+
"not-options",
|
|
56
|
+
"not-filter",
|
|
57
|
+
"not-key",
|
|
58
|
+
"not-ws",
|
|
59
|
+
"not-dbdump",
|
|
60
|
+
"not-user",
|
|
61
|
+
"not-store",
|
|
62
|
+
"not-error",
|
|
63
|
+
"not-inform",
|
|
64
|
+
"not-inform-rule-tag",
|
|
65
|
+
"not-inform-sink-email",
|
|
66
|
+
"not-inform-sink-ws",
|
|
67
|
+
];
|
|
68
|
+
export { DEFAULT_MODULES_SET_ENABLED };
|
|
69
|
+
|
|
70
|
+
const DEFAULT_NODE_API_URL = "https://appmon.ru/api/key/collect";
|
|
71
|
+
export { DEFAULT_NODE_API_URL };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default (inquirer) => {
|
|
2
|
+
return inquirer
|
|
3
|
+
.prompt([
|
|
4
|
+
{
|
|
5
|
+
type: "input",
|
|
6
|
+
name: "description",
|
|
7
|
+
message: "Application Description",
|
|
8
|
+
default: "notNodeApplication",
|
|
9
|
+
},
|
|
10
|
+
])
|
|
11
|
+
.then((answers) => {
|
|
12
|
+
return answers.description;
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DEFAULT_MODULE_ACTIONS } from "../const.mjs";
|
|
2
|
+
|
|
3
|
+
export default (inquirer) => {
|
|
4
|
+
return inquirer
|
|
5
|
+
.prompt([
|
|
6
|
+
{
|
|
7
|
+
type: "checkbox",
|
|
8
|
+
message: "Select entity actions",
|
|
9
|
+
name: "actions",
|
|
10
|
+
choices: DEFAULT_MODULE_ACTIONS.map((entry) => {
|
|
11
|
+
return {
|
|
12
|
+
name: entry,
|
|
13
|
+
checked: true,
|
|
14
|
+
};
|
|
15
|
+
}),
|
|
16
|
+
},
|
|
17
|
+
])
|
|
18
|
+
.then((answer) => {
|
|
19
|
+
let result = {};
|
|
20
|
+
answer.actions.forEach((entry) => {
|
|
21
|
+
result[entry] = { name: entry };
|
|
22
|
+
});
|
|
23
|
+
return result;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const kebabize = (str) => {
|
|
2
|
+
return str
|
|
3
|
+
.split("")
|
|
4
|
+
.map((letter, idx) => {
|
|
5
|
+
return letter.toUpperCase() === letter
|
|
6
|
+
? `${idx !== 0 ? "-" : ""}${letter.toLowerCase()}`
|
|
7
|
+
: letter;
|
|
8
|
+
})
|
|
9
|
+
.join("");
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default (inquirer, data) => {
|
|
13
|
+
return kebabize(data.AppName);
|
|
14
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default (inquirer) => {
|
|
2
|
+
return inquirer
|
|
3
|
+
.prompt([
|
|
4
|
+
{
|
|
5
|
+
type: "input",
|
|
6
|
+
name: "value",
|
|
7
|
+
message: "CORS (comma-separated: domain.com,list.foo.bar)",
|
|
8
|
+
default: "",
|
|
9
|
+
},
|
|
10
|
+
])
|
|
11
|
+
.then(({ value }) => value.split(",").map((entry) => entry.trim()));
|
|
12
|
+
};
|