not-node 6.1.2 → 6.1.3

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.
Files changed (66) hide show
  1. package/.vscode/launch.json +19 -0
  2. package/bin/not-cli.mjs +3 -8
  3. package/package.json +1 -1
  4. package/src/cli/readers/hostname.mjs +1 -1
  5. package/src/cli/readers/user.mjs +8 -1
  6. package/src/init/lib/modules.js +1 -2
  7. package/src/init/lib/routes.js +4 -1
  8. package/tmpl/files/app/app.ejs +3 -0
  9. package/playground/.babelrc +0 -11
  10. package/playground/.eslintignore +0 -4
  11. package/playground/.eslintrc.json +0 -23
  12. package/playground/app/front/build/admin.css +0 -2
  13. package/playground/app/front/build/admin.js +0 -52427
  14. package/playground/app/front/build/client.css +0 -2
  15. package/playground/app/front/build/client.js +0 -52427
  16. package/playground/app/front/build/guest.css +0 -2
  17. package/playground/app/front/build/guest.js +0 -50907
  18. package/playground/app/front/build/root.css +0 -2
  19. package/playground/app/front/build/root.js +0 -60023
  20. package/playground/app/front/build/user.css +0 -2
  21. package/playground/app/front/build/user.js +0 -52425
  22. package/playground/app/front/build.env.js +0 -15
  23. package/playground/app/front/index.!.js +0 -64
  24. package/playground/app/front/index.admin.js +0 -160
  25. package/playground/app/front/index.client.js +0 -160
  26. package/playground/app/front/index.guest.js +0 -160
  27. package/playground/app/front/index.root.js +0 -224
  28. package/playground/app/front/index.user.js +0 -160
  29. package/playground/app/front/rollup.!.js +0 -70
  30. package/playground/app/front/rollup.admin.js +0 -70
  31. package/playground/app/front/rollup.client.js +0 -70
  32. package/playground/app/front/rollup.guest.js +0 -70
  33. package/playground/app/front/rollup.root.js +0 -70
  34. package/playground/app/front/rollup.user.js +0 -70
  35. package/playground/app/front/src/admin/main/index.js +0 -45
  36. package/playground/app/front/src/client/main/index.js +0 -45
  37. package/playground/app/front/src/common/index.js +0 -39
  38. package/playground/app/front/src/common/ncInit.js +0 -18
  39. package/playground/app/front/src/common/ws.client.main.js +0 -35
  40. package/playground/app/front/src/guest/main/index.js +0 -34
  41. package/playground/app/front/src/root/main/index.js +0 -45
  42. package/playground/app/front/src/user/main/index.js +0 -45
  43. package/playground/app/server/app.js +0 -22
  44. package/playground/app/server/config/common.json +0 -99
  45. package/playground/app/server/config/development.json +0 -33
  46. package/playground/app/server/config/production.json +0 -33
  47. package/playground/app/server/config/stage.json +0 -33
  48. package/playground/app/server/index.js +0 -20
  49. package/playground/app/server/routes/index.js +0 -34
  50. package/playground/app/server/routes/site.js +0 -71
  51. package/playground/app/server/views/admin/foot.pug +0 -1
  52. package/playground/app/server/views/admin/head.pug +0 -7
  53. package/playground/app/server/views/admin/menu.pug +0 -2
  54. package/playground/app/server/views/admin.pug +0 -19
  55. package/playground/app/server/views/dashboard.pug +0 -20
  56. package/playground/app/server/views/index.pug +0 -15
  57. package/playground/app/server/views/parts/header.android.pug +0 -6
  58. package/playground/app/server/views/parts/header.ios.pug +0 -5
  59. package/playground/app/server/views/parts/header.pug +0 -18
  60. package/playground/app/server/views/parts/menu.pug +0 -1
  61. package/playground/app/server/views/parts/overview.pug +0 -2
  62. package/playground/app/server/ws/auth.js +0 -41
  63. package/playground/app/server/ws/index.js +0 -84
  64. package/playground/bin/build.sh +0 -8
  65. package/playground/package.json +0 -85
  66. package/playground/project.manifest.json +0 -37
@@ -1,20 +0,0 @@
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
- }
@@ -1,34 +0,0 @@
1
- const notNode = require("not-node"),
2
- { Auth, notAppIdentity } = require("not-node"),
3
- siteRouter = require("./site");
4
-
5
- module.exports = (web) => {
6
- web.get("/api/manifest", function (req, res) {
7
- notNode.notHeadersStyler.get()(req, res);
8
- res.status(200).json(notNode.Application.getManifest(req));
9
- });
10
-
11
- web.get(
12
- "/",
13
- (req, res, next) => {
14
- if (new notAppIdentity(req).isUser()) {
15
- res.redirect("/dashboard");
16
- } else {
17
- next();
18
- }
19
- },
20
- siteRouter.index
21
- );
22
-
23
- web.get(
24
- "/dashboard*",
25
- (req, res, next) => {
26
- if (new notAppIdentity(req).isUser()) {
27
- next();
28
- } else {
29
- res.redirect("/login");
30
- }
31
- },
32
- siteRouter.dashboard
33
- );
34
- };
@@ -1,71 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- script(src=host+"/front/root.js")
@@ -1,7 +0,0 @@
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")
@@ -1,2 +0,0 @@
1
- nav( class="col-md-2 d-none d-md-block bg-light sidebar")
2
- div(class="sidebar-sticky" id="mainMenu")
@@ -1,19 +0,0 @@
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
@@ -1,20 +0,0 @@
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")
@@ -1,15 +0,0 @@
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")
@@ -1,6 +0,0 @@
1
- <!-- Android -->
2
- meta(name="theme-color" content="#48c774")
3
- meta(name="color-scheme" content="light")
4
- meta(name="mobile-web-app-capable" content="yes")
5
- link(rel="stylesheet" href=host+"/front/"+role+".css")
6
- link(rel="stylesheet" href=host+"/assets/font-awesome.min.css")
@@ -1,5 +0,0 @@
1
- <!-- iOS -->
2
- meta(name="apple-mobile-web-app-title" content=title)
3
- meta(name="apple-mobile-web-app-capable" content="yes")
4
- meta(name="apple-mobile-web-app-status-bar-style" content="#48c774")
5
- link(rel="apple-touch-icon" href="./img/icons/icon-512.png")
@@ -1,18 +0,0 @@
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
@@ -1 +0,0 @@
1
- nav(class="navbar is-success" role="navigation" aria-label="dropdown navigation" id="top-menu")
@@ -1,2 +0,0 @@
1
- div(class="is-success is-fullheight")
2
- p Story of another little side project.
@@ -1,41 +0,0 @@
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
- };
@@ -1,84 +0,0 @@
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
- };
@@ -1,8 +0,0 @@
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
@@ -1,85 +0,0 @@
1
- {
2
- "name": "not-node-application",
3
- "version": "0.0.1",
4
- "description": "notNodeApplication",
5
- "main": "app/server/index.js",
6
- "private": true,
7
- "engines": {
8
- "node": ">14.9"
9
- },
10
- "scripts": {
11
- "start":"node ./app/server/index.js",
12
- "test": "./node_modules/.bin/mocha --reporter spec ./tests/**.js",
13
- "lint": "./node_modules/.bin/eslint ./app/**/**.js ./app/server/**/**/**.js ./app/server/**/**/**/**.js ./app/server/**/**/**/**/**.js --fix",
14
- "docs": "./node_modules/.bin/jsdoc -c jsdoc.json",
15
- "cover": "nyc npm test",
16
- "build:dev:guest:watch": "watch 'npm run build:dev:guest' ./app/front/src --interval=5",
17
- "build": "./node_modules/.bin/not-builder --config='./project.manifest.json'",
18
- "build:dev": "npm run development",
19
- "build:dev:guest": "./node_modules/.bin/not-builder --config='./project.manifest.json' --role=guest --environment=development",
20
- "build:dev:user": "./node_modules/.bin/not-builder --config='./project.manifest.json' --role=user --environment=development",
21
- "build:dev:client": "./node_modules/.bin/not-builder --config='./project.manifest.json' --role=client --environment=development",
22
- "build:dev:admin": "./node_modules/.bin/not-builder --config='./project.manifest.json' --role=admin --environment=development",
23
- "build:dev:root": "./node_modules/.bin/not-builder --config='./project.manifest.json' --role=root --environment=development",
24
- "archive": "./bin/archive.sh",
25
- "production": "./node_modules/.bin/not-builder --config='./project.manifest.json' --environment=production",
26
- "development": "./node_modules/.bin/not-builder --config='./project.manifest.json' --environment=development",
27
- "stage": "./node_modules/.bin/not-builder --config='./project.manifest.json' --environment=stage",
28
- "update": "ncu -u -x escape-string-regexp && npm i",
29
- "urd:dev": "npm run update && npm run build:dev && pm2 restart not-node-application.dev"
30
- },
31
- "dependencies": {
32
- "redis": "*",
33
- "pug":"*",
34
- "not-node": "*",
35
- "not-options":"*",
36
- "not-filter":"*",
37
- "not-notification":"*",
38
- "not-locale":"*",
39
- "not-inform":"*",
40
- "not-inform-rule-tag":"*",
41
- "not-inform-sink-email":"*",
42
- "not-inform-sink-notification":"*",
43
- "not-inform-sink-ws":"*",
44
- "not-key":"*",
45
- "not-ws":"*",
46
- "not-store":"*",
47
- "not-dbdump":"*",
48
- "not-user":"*",
49
- "not-error":"*",
50
-
51
- "dotenv": "*"
52
- },
53
- "devDependencies": {
54
- "@babel/core": "^7.18.9",
55
- "@babel/polyfill": "^7.12.1",
56
- "@babel/preset-env": "^7.18.9",
57
- "@babel/plugin-syntax-class-properties": "^7.12.13",
58
- "@rollup/plugin-babel": "^5.3.1",
59
- "@rollup/plugin-commonjs": "^22.0.1",
60
- "@rollup/plugin-node-resolve": "^13.3.0",
61
- "@rollup/plugin-json": "^4.1.0",
62
- "babel-core": "*",
63
- "babel-polyfill": "*",
64
- "babel-preset-es2015-rollup": "*",
65
- "babel-runtime": "*",
66
- "chai": "^4.3.6",
67
- "eslint": "^8.20.0",
68
- "ink-docstrap": "^1.3.2",
69
- "jsdoc": "^3.6.11",
70
- "mocha": "^10.0.0",
71
- "ndb": "^1.1.5",
72
- "nyc": "^15.1.0",
73
- "rollup": "^2.77.2",
74
- "rollup-plugin-postcss": "^4.0.2",
75
- "rollup-plugin-sass": "^1.2.13",
76
- "rollup-plugin-svelte": "^7.1.0",
77
- "rollup-plugin-eslint": "^7.0.0",
78
- "rollup-plugin-filesize": "^9.1.2",
79
- "rollup-plugin-sizes": "^1.0.4",
80
- "rollup-watch": "*",
81
- "should": "^13.2.3",
82
- "svelte": "*",
83
- "yargs": "^17.5.1"
84
- }
85
- }
@@ -1,37 +0,0 @@
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-notification": {},
20
- "not-locale": {},
21
- "not-inform": {},
22
- "not-inform-rule-tag": {},
23
- "not-inform-sink-email": {},
24
- "not-inform-sink-notification": {},
25
- "not-inform-sink-ws": {},
26
- "not-key": {},
27
- "not-ws": {},
28
- "not-store": {},
29
- "not-dbdump": {},
30
- "not-user": {},
31
- "not-error": {}
32
-
33
- }
34
- }
35
- }
36
- }
37
- }