not-node 6.1.2 → 6.1.4

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 (34) hide show
  1. package/.vscode/launch.json +19 -0
  2. package/bin/not-cli.mjs +6 -11
  3. package/package.json +1 -1
  4. package/playground/app/front/build/admin.js +21 -29
  5. package/playground/app/front/build/client.js +21 -29
  6. package/playground/app/front/build/guest.css +1 -1
  7. package/playground/app/front/build/guest.js +29 -21
  8. package/playground/app/front/build/root.js +21 -29
  9. package/playground/app/front/build/user.js +21 -29
  10. package/playground/app/front/src/admin/main/index.js +14 -25
  11. package/playground/app/front/src/client/main/index.js +14 -25
  12. package/playground/app/front/src/common/index.js +3 -2
  13. package/playground/app/front/src/common/ws.client.main.js +2 -3
  14. package/playground/app/front/src/guest/main/index.js +25 -14
  15. package/playground/app/front/src/root/main/index.js +14 -25
  16. package/playground/app/front/src/user/main/index.js +14 -25
  17. package/playground/app/server/app.js +3 -0
  18. package/playground/app/server/config/common.json +98 -91
  19. package/playground/app/server/config/development.json +32 -31
  20. package/playground/app/server/config/production.json +32 -31
  21. package/playground/app/server/config/stage.json +32 -31
  22. package/playground/app/server/views/parts/menu.pug +1 -1
  23. package/playground/app/server/views/parts/overview.pug +1 -1
  24. package/src/cli/readers/hostname.mjs +1 -1
  25. package/src/cli/readers/user.mjs +8 -1
  26. package/src/cli/readers/ws.mjs +12 -0
  27. package/src/cli/renderers/controllers.mjs +1 -0
  28. package/src/init/lib/modules.js +1 -2
  29. package/src/init/lib/routes.js +4 -1
  30. package/tmpl/dirs/module.front.mjs +1 -1
  31. package/tmpl/files/app/app.ejs +3 -0
  32. package/tmpl/files/module.front/common/index.ejs +7 -6
  33. package/tmpl/files/module.front/common/ws.client.main.ejs +2 -3
  34. package/tmpl/files/module.front/role/index.ejs +1 -1
@@ -1,99 +1,106 @@
1
1
  {
2
- "port": 3000,
3
- "host": "localhost",
4
- "cors": [
5
- ""
6
- ],
7
- "template": {
8
- "engine": "pug",
9
- "views": "views",
10
- "partialsDir": "partials",
11
- "partials": {}
12
- },
13
- "db": {
14
- "mongoose": {
15
- "uri": "mongodb:///test?authSource=admin",
16
- "options": {
17
- "useNewUrlParser": true,
18
- "useUnifiedTopology": true,
19
- "db": "test",
20
- "host": "",
21
- "user": "tester",
22
- "pass": "test",
23
- "autoIndex": false
2
+ "port": 3000,
3
+ "host": "localhost",
4
+ "cors": [""],
5
+ "template": {
6
+ "engine": "pug",
7
+ "views": "views",
8
+ "partialsDir": "partials",
9
+ "partials": {}
10
+ },
11
+
12
+ "db": {
13
+
14
+ "mongoose": {
15
+ "uri": "mongodb:///test?authSource=admin",
16
+ "options": {
17
+ "useNewUrlParser": true,
18
+ "useUnifiedTopology": true,
19
+ "db": "test",
20
+ "host": "",
21
+ "user": "tester",
22
+ "pass": "test",
23
+ "autoIndex": false
24
+ }
25
+ },
26
+
27
+
28
+ "redis": {},
29
+
30
+
31
+ "ioredis": {
32
+ "enableOfflineQueue": false
24
33
  }
34
+
35
+ },
36
+
37
+
38
+ "session": {
39
+ "driver": "redis",
40
+ "secret": "mlI1kwtmLRmcScfro2ftMkkifJIzlJBQ2FvITbKM",
41
+ "cookie": {
42
+ "maxAge": 2628000000
43
+ },
44
+ "key": "SessionID"
25
45
  },
26
- "redis": {},
27
- "ioredis": {
28
- "enableOfflineQueue": false
29
- }
30
- },
31
- "session": {
32
- "driver": "redis",
33
- "secret": "yPSvHeEQFmvFVYEf7U6ax6e4mRupDKlt7IKnDT8H",
34
- "cookie": {
35
- "maxAge": 2628000000
46
+
47
+
48
+ "path": {
49
+ "static": "../static",
50
+ "app": "/client",
51
+ "dbDumps": "../../../db.dumps",
52
+ "front": "../front/build",
53
+ "ws": "./ws"
36
54
  },
37
- "key": "SessionID"
38
- },
39
- "path": {
40
- "static": "../static",
41
- "app": "/client",
42
- "dbDumps": "../../../db.dumps",
43
- "front": "../front/build",
44
- "ws": "./ws"
45
- },
46
- "defaultUserRole": "user",
47
- "modules": {
48
- "ws": {
49
- "servers": {
50
- "main": {
51
- "connection": {
52
- "port": 3030,
53
- "secure": true,
54
- "secret": "2stgKj4IqCqsGE5NBV1yNQnSYR1ITyuqwro934aV"
55
+ "defaultUserRole": "user",
56
+ "modules": {
57
+
58
+ "ws": {
59
+ "servers": {
60
+ "main": {
61
+ "connection": {
62
+ "port": 3030,
63
+ "secure": true,
64
+ "secret": "zZswkyHax9xzb3hMn6fsxJkJnK2dFF02gpKTnQwh"
65
+ }
55
66
  }
56
67
  }
68
+ },
69
+
70
+
71
+ "user": {
72
+ "errors":{
73
+ "noUserData": false,
74
+ "noUserWithId": false
75
+ },
76
+ "debug":{
77
+ "loaded": false
78
+ },
79
+ "tokenTTL": 3600,
80
+ "secret": "zZswkyHax9xzb3hMn6fsxJkJnK2dFF02gpKTnQwh",
81
+ "roles": {
82
+ "primary": ["root","admin","client","user","guest"],
83
+ "secondary": ["confirmed","manager"]
84
+ },
85
+ "restrict": {
86
+ "registration": false
87
+ }
88
+ },
89
+
90
+
91
+
92
+ "rateLimiter": {
93
+ "keyPrefix": "rateLimiterMiddleware",
94
+ "points": 500,
95
+ "duration": 1
57
96
  }
97
+
98
+ },
99
+ "middleware": {
100
+ "not-options": {},"not-filter": {},"not-notification": {},"not-locale": {},"not-inform": {},"not-inform-rule-tag": {},"not-inform-sink-email": {},"not-inform-sink-notification": {},"not-inform-sink-ws": {},"not-key": {},"not-ws": {},"not-store": {},"not-dbdump": {},"not-user": {},"not-error": {}
58
101
  },
59
- "rateLimiter": {
60
- "keyPrefix": "rateLimiterMiddleware",
61
- "points": 500,
62
- "duration": 1
63
- }
64
- },
65
- "middleware": {
66
- "not-options": {},
67
- "not-filter": {},
68
- "not-notification": {},
69
- "not-locale": {},
70
- "not-inform": {},
71
- "not-inform-rule-tag": {},
72
- "not-inform-sink-email": {},
73
- "not-inform-sink-notification": {},
74
- "not-inform-sink-ws": {},
75
- "not-key": {},
76
- "not-ws": {},
77
- "not-store": {},
78
- "not-dbdump": {},
79
- "not-user": {},
80
- "not-error": {}
81
- },
82
- "importModulesFromNPM": [
83
- "not-options",
84
- "not-filter",
85
- "not-notification",
86
- "not-locale",
87
- "not-inform",
88
- "not-inform-rule-tag",
89
- "not-inform-sink-email",
90
- "not-inform-sink-notification",
91
- "not-inform-sink-ws",
92
- "not-key",
93
- "not-ws",
94
- "not-store",
95
- "not-dbdump",
96
- "not-user",
97
- "not-error"
98
- ]
99
- }
102
+ "importModulesFromNPM": [
103
+ "not-options","not-filter","not-notification","not-locale","not-inform","not-inform-rule-tag","not-inform-sink-email","not-inform-sink-notification","not-inform-sink-ws","not-key","not-ws","not-store","not-dbdump","not-user","not-error"
104
+ ]
105
+ }
106
+
@@ -1,33 +1,34 @@
1
1
  {
2
- "hostname": "localhost",
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
- ]
2
+ "hostname":"localhost",
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
+ }
32
33
  }
33
- }
34
+
@@ -1,33 +1,34 @@
1
1
  {
2
- "hostname": "localhost",
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
- ]
2
+ "hostname":"localhost",
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
+ }
32
33
  }
33
- }
34
+
@@ -1,33 +1,34 @@
1
1
  {
2
- "hostname": "localhost",
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
- ]
2
+ "hostname":"localhost",
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
+ }
32
33
  }
33
- }
34
+
@@ -1 +1 @@
1
- nav(class="navbar is-success" role="navigation" aria-label="dropdown navigation" id="top-menu")
1
+ nav(class="navbar is-success" role="navigation" aria-label="dropdown navigation" id="top-menu")
@@ -1,2 +1,2 @@
1
1
  div(class="is-success is-fullheight")
2
- p Story of another little side project.
2
+ p Story of another little side project.
@@ -1,4 +1,4 @@
1
- const DEFAULT_HOST = "https://localhost";
1
+ const DEFAULT_HOST = "localhost";
2
2
  export default (inquirer) => {
3
3
  return inquirer.prompt([
4
4
  {
@@ -1,3 +1,10 @@
1
+ const DEFAULT_CONFIG = {
2
+ restrict: {
3
+ registration: false,
4
+ },
5
+ tokenTTL: 3600,
6
+ };
7
+
1
8
  function collectRestrictions(inquirer) {
2
9
  return inquirer.prompt([
3
10
  {
@@ -56,7 +63,7 @@ export default (inquirer) => {
56
63
  if (answer.enabled) {
57
64
  return collectData(inquirer);
58
65
  } else {
59
- return false;
66
+ return DEFAULT_CONFIG;
60
67
  }
61
68
  });
62
69
  };
@@ -1,11 +1,23 @@
1
1
  function collectData(inquirer) {
2
2
  return inquirer.prompt([
3
+ {
4
+ type: "input",
5
+ name: "hostname",
6
+ message: "WS hostname (default: window.location.hostname)",
7
+ default: "",
8
+ },
3
9
  {
4
10
  type: "input",
5
11
  name: "port",
6
12
  message: "WS port number",
7
13
  default: 33000,
8
14
  },
15
+ {
16
+ type: "input",
17
+ name: "path",
18
+ message: "WS path ",
19
+ default: "websocket",
20
+ },
9
21
  {
10
22
  type: "config",
11
23
  name: "secure",
@@ -20,6 +20,7 @@ export default async (
20
20
  );
21
21
  await createFileContent(TMPL_FILE_PATH, DEST_FILE_PATH, {
22
22
  ...config,
23
+ roleName,
23
24
  ...data,
24
25
  });
25
26
  }
@@ -1,6 +1,5 @@
1
1
  module.exports = class InitModules {
2
2
  async run({ master }) {
3
- master.getApp().execInModules("initialize", master);
4
- master.getApp().execInModules("registerPagesRoutes", master);
3
+ await master.getApp().execInModules("initialize", master);
5
4
  }
6
5
  };
@@ -59,9 +59,12 @@ module.exports = class InitRoutes {
59
59
 
60
60
  async run({ master, config, options }) {
61
61
  log.info("Setting up routes...");
62
+ //pages rendering
63
+ await master.getApp().execInModules("registerPagesRoutes", master);
64
+ //api first
62
65
  master.getApp().expose(master.getServer());
66
+ //user defined pages
63
67
  require(options.routesPath)(master.getServer(), master.getApp());
64
-
65
68
  master.getServer().use(serveStatic(config.get("staticPath")));
66
69
  master.getServer().use(options.indexRoute);
67
70
  master.getServer().use(
@@ -3,7 +3,7 @@ export default {
3
3
  content: {
4
4
  "index.js": {
5
5
  tmpl: "module.front/common/index.ejs",
6
- args: ["modules", "AppName"],
6
+ args: ["modules", "AppName", "ssl", "ws"],
7
7
  },
8
8
  "ncInit.js": {
9
9
  tmpl: "module.front/common/ncInit.ejs",
@@ -1,5 +1,7 @@
1
1
  const notNode = require("not-node");
2
2
 
3
+ const InitIdentityTokens = require("not-user").InitIdentityTokens;
4
+
3
5
  const Init = require("not-node").Init,
4
6
  path = require("path"),
5
7
  manifest = require("./../../project.manifest.json");
@@ -15,6 +17,7 @@ module.exports = () => {
15
17
  const additional = {
16
18
  pre({ initSequence }) {
17
19
  initSequence.remove("InitMonitoring");
20
+ initSequence.insert(InitIdentityTokens);
18
21
  },
19
22
  };
20
23
 
@@ -1,4 +1,4 @@
1
- <% if(modules.includes('not-ws')){ %>
1
+ <% if(modules.includes('not-ws') && ws){ %>
2
2
  import main from './ws.client.main.js';
3
3
  <% } %>
4
4
 
@@ -13,15 +13,16 @@ let manifest = {
13
13
  url: '/'
14
14
  },
15
15
  modules:{
16
- <% if(modules.includes('not-ws')){ %>
16
+ <% if(modules.includes('not-ws') && ws){ %>
17
17
  ws:{
18
18
  clients:{
19
19
  //options for ws client here
20
20
  main: {
21
- host: window.location.hostname,
22
- path: 'websocket',
23
- secure: true,
24
- ssl: true
21
+ host: '<%- ws.hostname %>' || window.location.hostname,
22
+ port: <%- ws.port %>,
23
+ path: '<%- ws.path %>',
24
+ secure: <%- ws.secure %>,
25
+ ssl: <%- !!ssl %>
25
26
  }
26
27
  }
27
28
  }
@@ -6,9 +6,8 @@ const main = {
6
6
  getToken: () => {
7
7
  return notCommon.getApp().getModel('user', {}).$token({})
8
8
  .then((res) => {
9
- logger.log('token', res.result.token);
10
- notCommon.getApp().setWorking('token', res.result.token);
11
- return res.result.token;
9
+ notCommon.getApp().setWorking('token', res.result);
10
+ return res.result;
12
11
  });
13
12
  },
14
13
  messenger: {
@@ -1,7 +1,7 @@
1
1
  import ncInit from "../../common/ncInit";
2
2
 
3
3
  let manifest = {
4
- environment: "client",
4
+ environment: "<%- roleName %>",
5
5
  router: {
6
6
  root: "/dashboard",
7
7
  manifest: [],