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,16 @@
|
|
|
1
|
+
<% if (not_node_reporter) %{ %>
|
|
2
|
+
NOT_NODE_ERROR_KEY=<%- not_node_reporter.key %>
|
|
3
|
+
NOT_NODE_ERROR_URL_NODE=<%- not_node_reporter.url_node %>
|
|
4
|
+
NOT_NODE_ERROR_URL_BROWSER=<%- not_node_reporter.url_browser %>
|
|
5
|
+
<% } %>
|
|
6
|
+
<% if (not_node_monitor) %{ %>
|
|
7
|
+
NOT_NODE_MONITOR_INTERVAL=<%- not_node_monitor.interval %>
|
|
8
|
+
NOT_NODE_MONITOR_REPORT_INTERVAL=<%- not_node_monitor.report_interval %>
|
|
9
|
+
NOT_NODE_MONITOR_REPORT_KEY=<%- not_node_monitor.report_key %>
|
|
10
|
+
NOT_NODE_MONITOR_REPORT_URL=<%- not_node_monitor.report_url %>
|
|
11
|
+
<% } %>
|
|
12
|
+
<% if (init_root_user) %{ %>
|
|
13
|
+
INIT_ROOT_USERNAME=<%- init_root_user.name %>
|
|
14
|
+
INIT_ROOT_EMAIL=<%- init_root_user.email %>
|
|
15
|
+
INIT_ROOT_PASSWORD=<%- init_root_user.password %>
|
|
16
|
+
<% } %>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<% if (not_node_reporter) { %>
|
|
2
|
+
window.NOT_NODE_ERROR_URL_BROWSER = '<%- not_node_reporter.url_browser %>';
|
|
3
|
+
<% } %>
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Frame
|
|
7
|
+
} from 'not-bulma';
|
|
8
|
+
|
|
9
|
+
const {notCommon, notApp, COMPONENTS} = Frame;
|
|
10
|
+
|
|
11
|
+
notCommon.register('backlog', true);
|
|
12
|
+
window.dumpBacklog = notCommon.dumpBacklog.bind(notCommon);
|
|
13
|
+
|
|
14
|
+
let appDefaultOptions = {
|
|
15
|
+
manifestURL: '/api/manifest',
|
|
16
|
+
router: {
|
|
17
|
+
root: '/',
|
|
18
|
+
manifest: [],
|
|
19
|
+
index: ''
|
|
20
|
+
},
|
|
21
|
+
language: 'ru',
|
|
22
|
+
crud: {
|
|
23
|
+
navigateBackAfter: ['create', 'update', 'delete']
|
|
24
|
+
},
|
|
25
|
+
modules: {
|
|
26
|
+
user: {
|
|
27
|
+
redirectTimout: 1000,
|
|
28
|
+
afterLoginURL: '/dashboard',
|
|
29
|
+
loginForm: {
|
|
30
|
+
modes: [
|
|
31
|
+
'login',
|
|
32
|
+
'requestLoginCodeOnEmail',
|
|
33
|
+
'loginByCode'
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
loginFormContainerSelector: '.main-container',
|
|
37
|
+
restoreFormContainerSelector: '.main-container',
|
|
38
|
+
registerFormContainerSelector: '.main-container'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
let services = {}, uis = {}, wsc = {}, fields = {};
|
|
44
|
+
|
|
45
|
+
<%% for(var i = 0; i < mods.length; i++) { %%>
|
|
46
|
+
import * as mod_<%%= i %%>
|
|
47
|
+
from '<%%= mods[i] %%>';
|
|
48
|
+
appDefaultOptions = notCommon.absorbModule({
|
|
49
|
+
defaultConf: appDefaultOptions,
|
|
50
|
+
mod: mod_<%%= i %%>,
|
|
51
|
+
services, uis, wsc, fields
|
|
52
|
+
});
|
|
53
|
+
<%% } %%>
|
|
54
|
+
|
|
55
|
+
COMPONENTS.import(uis);
|
|
56
|
+
|
|
57
|
+
import 'bulma';
|
|
58
|
+
|
|
59
|
+
<%% for(var i = 0; i < scss.length; i++) { %%>
|
|
60
|
+
import '<%%= scss[i] %%>';
|
|
61
|
+
<%% } %%>
|
|
62
|
+
|
|
63
|
+
appDefaultOptions.services = services;
|
|
64
|
+
appDefaultOptions.wsc = wsc;
|
|
65
|
+
|
|
66
|
+
notCommon.startApp(() => new notApp(appDefaultOptions));
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Rollup plugins
|
|
2
|
+
import babel from "@rollup/plugin-babel";
|
|
3
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
4
|
+
import svelte from "rollup-plugin-svelte";
|
|
5
|
+
import resolve from "@rollup/plugin-node-resolve";
|
|
6
|
+
import filesize from "rollup-plugin-filesize";
|
|
7
|
+
import sizes from "rollup-plugin-sizes";
|
|
8
|
+
import postcss from "rollup-plugin-postcss";
|
|
9
|
+
import json from "@rollup/plugin-json";
|
|
10
|
+
|
|
11
|
+
import { babelOn } from "./build.env.js";
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
input: "<%%= inputPath %%>",
|
|
15
|
+
output: {
|
|
16
|
+
file: "<%%= outputPath %%>",
|
|
17
|
+
name: "<%%= appName %%>",
|
|
18
|
+
format: "iife",
|
|
19
|
+
sourcemap:
|
|
20
|
+
false && (process.env.NODE_ENV === "production" ? false : "inline"),
|
|
21
|
+
},
|
|
22
|
+
plugins: [
|
|
23
|
+
json(),
|
|
24
|
+
svelte({
|
|
25
|
+
emitCss: true,
|
|
26
|
+
}),
|
|
27
|
+
resolve({
|
|
28
|
+
browser: true,
|
|
29
|
+
preferBuiltins: true,
|
|
30
|
+
dedupe: (importee) =>
|
|
31
|
+
importee === "svelte" || importee.startsWith("svelte/"),
|
|
32
|
+
}),
|
|
33
|
+
commonjs({}),
|
|
34
|
+
postcss({
|
|
35
|
+
extract: true,
|
|
36
|
+
minimize: true,
|
|
37
|
+
use: [
|
|
38
|
+
[
|
|
39
|
+
"sass",
|
|
40
|
+
{
|
|
41
|
+
includePaths: ["./src/styles/theme", "./node_modules"],
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
],
|
|
45
|
+
}),
|
|
46
|
+
babelOn() &&
|
|
47
|
+
babel({
|
|
48
|
+
presets: [
|
|
49
|
+
[
|
|
50
|
+
"@babel/preset-env",
|
|
51
|
+
{
|
|
52
|
+
corejs: 3,
|
|
53
|
+
modules: false,
|
|
54
|
+
useBuiltIns: "usage",
|
|
55
|
+
targets: "> 2.5%, not dead",
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
],
|
|
59
|
+
babelHelpers: "bundled",
|
|
60
|
+
plugins: [
|
|
61
|
+
"@babel/plugin-proposal-class-properties",
|
|
62
|
+
"@babel/plugin-proposal-private-methods",
|
|
63
|
+
"@babel/transform-arrow-functions",
|
|
64
|
+
],
|
|
65
|
+
exclude: ["node_modules/**", "build/**"],
|
|
66
|
+
}),
|
|
67
|
+
sizes(),
|
|
68
|
+
filesize(),
|
|
69
|
+
],
|
|
70
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const env = process.env.NODE_ENV || 'development';
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
require('dotenv').config({ path: path.resolve(__dirname, '../../../.env')});
|
|
5
|
+
|
|
6
|
+
const configPath = path.join(__dirname, 'config');
|
|
7
|
+
const configModule = require('not-config');
|
|
8
|
+
|
|
9
|
+
//инициализируем доступ к логам
|
|
10
|
+
const log = require('not-log')(module, 'init');
|
|
11
|
+
log.info('Environment', env, configPath);
|
|
12
|
+
|
|
13
|
+
//иницилизируем доступ к настройкам
|
|
14
|
+
const configLoaded = configModule.init(configPath);
|
|
15
|
+
if (configLoaded !== false){
|
|
16
|
+
log.info('Config loaded: ', configPath);
|
|
17
|
+
require('./app.js')();
|
|
18
|
+
}else{
|
|
19
|
+
log.error('Config not loaded: ', configPath);
|
|
20
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%- appName %>",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "<%- AppDescription %>",
|
|
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 <%- appName %>.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,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%- AppName %>",
|
|
3
|
+
"targets": {
|
|
4
|
+
"server": {
|
|
5
|
+
"name": "<%- AppName %>",
|
|
6
|
+
"roles": [<% roles.forEach(function(role, index){ %>"<%- role %>"<%- (roles.length - 1 > index)?',':'' %><% }); %>],
|
|
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
|
+
<% modules.forEach(function(module, index){ %>"<%- module %>": {}<%- (modules.length - 1 > index)?',':'' %>
|
|
18
|
+
<% }); %>
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -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: "<%- AppName %>",
|
|
7
|
+
desription: "<%- AppDescription %>",
|
|
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,39 @@
|
|
|
1
|
+
<% if(modules.includes('not-ws')){ %>
|
|
2
|
+
import main from './ws.client.main.js';
|
|
3
|
+
<% } %>
|
|
4
|
+
|
|
5
|
+
let manifest = {
|
|
6
|
+
brand: {
|
|
7
|
+
icon: {
|
|
8
|
+
src: '/img/icons/icon-w-64.png',
|
|
9
|
+
width: 48,
|
|
10
|
+
height: 28
|
|
11
|
+
},
|
|
12
|
+
title: '<%- AppName %>',
|
|
13
|
+
url: '/'
|
|
14
|
+
},
|
|
15
|
+
modules:{
|
|
16
|
+
<% if(modules.includes('not-ws')){ %>
|
|
17
|
+
ws:{
|
|
18
|
+
clients:{
|
|
19
|
+
//options for ws client here
|
|
20
|
+
main: {
|
|
21
|
+
host: window.location.hostname,
|
|
22
|
+
path: 'websocket',
|
|
23
|
+
secure: true,
|
|
24
|
+
ssl: true
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
<% } %>
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const wsc = {
|
|
33
|
+
main
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
manifest,
|
|
38
|
+
wsc
|
|
39
|
+
};
|