not-node 6.1.0 → 6.1.1

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/.env ADDED
@@ -0,0 +1,12 @@
1
+ NOT_NODE_ERROR_KEY=2f721c40-30c5-4f35-9e45-cfea1be33f03
2
+ NOT_NODE_ERROR_URL_NODE=https://reporter.local/api/key/collect
3
+ NOT_NODE_ERROR_URL_BROWSER=https://reporter.local/api/key/collect
4
+ INIT_ROOT_USERNAME=root
5
+ INIT_ROOT_EMAIL=admin@appmon.ru
6
+ INIT_ROOT_PASSWORD=tester
7
+ db__mongoose__uri=mongodb://localhost/reporter?authSource=reporter
8
+ db__mongoose__options__user=reporter.production
9
+ db__mongoose__options__pass=production.reporter
10
+ db__mongoose__options__db=reporter
11
+ db__mongoose__options__host=localhost
12
+ db__mongoose__options__authSource=reporter
package/bin/not-cli.mjs CHANGED
@@ -8,8 +8,9 @@ import { isAbsolute, resolve, join } from "node:path";
8
8
 
9
9
  import { copyFile, constants, mkdir, writeFile } from "node:fs/promises";
10
10
 
11
- import { cwd } from "node:process";
11
+ import { cwd, stdout, stderr } from "node:process";
12
12
  const CWD = cwd();
13
+ import { spawn } from "node:child_process";
13
14
 
14
15
  import * as url from "url";
15
16
  const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
@@ -330,7 +331,9 @@ program
330
331
  .addOption(
331
332
  new Option("-d, --dir <dir>").default(CWD, "current working directory")
332
333
  )
333
- .description("create application in target directory")
334
+ .description(
335
+ "create application in target directory (create -d [pathToDir])"
336
+ )
334
337
  .action(async (opts) => {
335
338
  // console.log("create command called :" + opts.dir);
336
339
  if (!isAbsolute(opts.dir)) {
@@ -364,6 +367,19 @@ program
364
367
  if (await Readers.isUserNeedFrontModuleBootstrap(inquirer)) {
365
368
  await createBootstrapFrontModule(PATH_MODULES_FRONT, AppConfig);
366
369
  }
370
+ console.log(`cd '${opts.dir}' && npm i`);
371
+ let npmInstall = spawn(`npm`, ["i"], { cwd: opts.dir });
372
+ npmInstall.stdout.on("data", (data) => {
373
+ console.log(data.toString());
374
+ });
375
+
376
+ npmInstall.stderr.on("data", (data) => {
377
+ console.error(data.toString());
378
+ });
379
+
380
+ npmInstall.on("exit", (code) => {
381
+ console.log(`NPM install exited with code ${code}`);
382
+ });
367
383
  });
368
384
 
369
385
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "6.1.0",
3
+ "version": "6.1.1",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,15 @@
1
+
2
+ let replaceSets = {
3
+ development: {},
4
+ production: {},
5
+ stage: {},
6
+ };
7
+
8
+ let babelOn = () => {
9
+ return ['production', 'stage', 'development'].indexOf(process.env.NODE_ENV) > -1;
10
+ };
11
+
12
+ export {
13
+ babelOn,
14
+ replaceSets
15
+ };
@@ -1,53 +1,99 @@
1
1
  {
2
- "port": 3000,
3
- "host": "https://localhost",
4
- "cors": [""],
5
- "template": {
6
- "engine": "pug",
7
- "views": "views",
8
- "partialsDir": "partials",
9
- "partials": {}
10
- },
11
-
12
- "db": {
13
-
14
-
15
- "redis": {},
16
-
17
-
18
- "ioredis": {
19
- "enableOfflineQueue": false
2
+ "port": 3000,
3
+ "host": "https://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
20
24
  }
21
-
22
25
  },
23
-
24
-
25
-
26
- "path": {
27
- "static": "../static",
28
- "app": "/client",
29
- "dbDumps": "../../../db.dumps",
30
- "front": "../front/build",
31
- "ws": "./ws"
26
+ "redis": {},
27
+ "ioredis": {
28
+ "enableOfflineQueue": false
29
+ }
30
+ },
31
+ "session": {
32
+ "driver": "redis",
33
+ "secret": "NG1ARzt2kIFQ82GbldZACMYE12xBiuRnPObMqeba",
34
+ "cookie": {
35
+ "maxAge": 2628000000
32
36
  },
33
- "defaultUserRole": "user",
34
- "modules": {
35
-
36
-
37
-
38
-
39
- "rateLimiter": {
40
- "keyPrefix": "rateLimiterMiddleware",
41
- "points": 500,
42
- "duration": 1
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": 303,
53
+ "secure": true,
54
+ "secret": "Nqh6DCD9lZ0Px575JmBJuimO1giVlPgBbjEHhHmE"
55
+ }
56
+ }
43
57
  }
44
-
45
- },
46
- "middleware": {
47
- "not-options": {},"not-filter": {},"not-inform": {},"not-inform-rule-tag": {},"not-inform-sink-email": {},"not-inform-sink-ws": {},"not-key": {},"not-ws": {},"not-store": {},"not-dbdump": {},"not-user": {},"not-error": {}
48
58
  },
49
- "importModulesFromNPM": [
50
- "not-options","not-filter","not-inform","not-inform-rule-tag","not-inform-sink-email","not-inform-sink-ws","not-key","not-ws","not-store","not-dbdump","not-user","not-error"
51
- ]
52
- }
53
-
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
+ }
@@ -2,12 +2,13 @@
2
2
  "name": "not-node-application",
3
3
  "version": "0.0.1",
4
4
  "description": "notNodeApplication",
5
- "main": "app.js",
5
+ "main": "app/server/index.js",
6
6
  "private": true,
7
7
  "engines": {
8
8
  "node": ">14.9"
9
9
  },
10
10
  "scripts": {
11
+ "start":"node ./app/server/index.js",
11
12
  "test": "./node_modules/.bin/mocha --reporter spec ./tests/**.js",
12
13
  "lint": "./node_modules/.bin/eslint ./app/**/**.js ./app/server/**/**/**.js ./app/server/**/**/**/**.js ./app/server/**/**/**/**/**.js --fix",
13
14
  "docs": "./node_modules/.bin/jsdoc -c jsdoc.json",
@@ -29,7 +30,25 @@
29
30
  },
30
31
  "dependencies": {
31
32
  "redis": "*",
32
- "not-node": "*"
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": "*"
33
52
  },
34
53
  "devDependencies": {
35
54
  "@babel/core": "^7.18.9",
@@ -16,9 +16,12 @@
16
16
  "npm": {
17
17
  "not-options": {},
18
18
  "not-filter": {},
19
+ "not-notification": {},
20
+ "not-locale": {},
19
21
  "not-inform": {},
20
22
  "not-inform-rule-tag": {},
21
23
  "not-inform-sink-email": {},
24
+ "not-inform-sink-notification": {},
22
25
  "not-inform-sink-ws": {},
23
26
  "not-key": {},
24
27
  "not-ws": {},
@@ -1,8 +1,9 @@
1
1
  const DEFAULT = {
2
2
  db: "test",
3
3
  host: "localhost",
4
- user: "",
5
- pass: "",
4
+ user: "tester",
5
+ pass: "test",
6
+ authSource: "admin",
6
7
  };
7
8
 
8
9
  function collectData(inquirer) {
@@ -36,24 +37,43 @@ function collectData(inquirer) {
36
37
  type: "input",
37
38
  name: "authSource",
38
39
  message: "MongoDB authSource",
39
- default: "admin",
40
+ default: DEFAULT.authSource,
40
41
  },
41
42
  ]);
42
43
  }
43
44
 
45
+ function needToConfigure(inquirer) {
46
+ return inquirer
47
+ .prompt([
48
+ {
49
+ type: "confirm",
50
+ name: "configure",
51
+ message: "Configure mongoose connection?",
52
+ default: false,
53
+ },
54
+ ])
55
+ .then((answer) => {
56
+ if (answer.configure) {
57
+ return collectData(inquirer);
58
+ } else {
59
+ return DEFAULT;
60
+ }
61
+ });
62
+ }
63
+
44
64
  export default (inquirer) => {
45
65
  return inquirer
46
66
  .prompt([
47
67
  {
48
68
  type: "confirm",
49
69
  name: "enabled",
50
- message: "Configure mongoose?",
70
+ message: "Add mongoose connection?",
51
71
  default: false,
52
72
  },
53
73
  ])
54
74
  .then((answer) => {
55
75
  if (answer.enabled) {
56
- return collectData(inquirer);
76
+ return needToConfigure(inquirer);
57
77
  } else {
58
78
  return false;
59
79
  }
@@ -5,6 +5,13 @@ const DEFAULT_SECRET = generator.generate({
5
5
  numbers: true,
6
6
  });
7
7
 
8
+ const DEFAULT_SESSION_OPTIONS = {
9
+ driver: "redis",
10
+ secret: DEFAULT_SECRET,
11
+ ttl: 2628000000,
12
+ key: "SessionID",
13
+ };
14
+
8
15
  function collectData(inquirer) {
9
16
  return inquirer.prompt([
10
17
  {
@@ -41,7 +48,7 @@ export default (inquirer) => {
41
48
  {
42
49
  type: "confirm",
43
50
  name: "enabled",
44
- message: "Configure Session module?",
51
+ message: "Change default configuration of sessions module?",
45
52
  default: false,
46
53
  },
47
54
  ])
@@ -49,7 +56,7 @@ export default (inquirer) => {
49
56
  if (answer.enabled) {
50
57
  return collectData(inquirer);
51
58
  } else {
52
- return false;
59
+ return DEFAULT_SESSION_OPTIONS;
53
60
  }
54
61
  });
55
62
  };
package/src/common.js CHANGED
@@ -156,9 +156,23 @@ module.exports.executeFunctionAsAsync = executeFunctionAsAsync;
156
156
  **/
157
157
  module.exports.executeObjectFunction = async (obj, name, params) => {
158
158
  if (obj) {
159
- const proc =
160
- typeof obj == "object" ? notPath.get(":" + name, obj) : obj[name];
161
- return await executeFunctionAsAsync(proc, params);
159
+ if (name.indexOf(".") > -1) {
160
+ const proc =
161
+ typeof obj == "object"
162
+ ? notPath.get(":" + name, obj)
163
+ : obj[name];
164
+ if (proc) {
165
+ return await executeFunctionAsAsync(proc.bind(obj), params);
166
+ }
167
+ } else {
168
+ if (obj[name] && isFunc(obj[name])) {
169
+ if (isAsync(obj[name])) {
170
+ return await obj[name](...params);
171
+ } else {
172
+ return obj[name](...params);
173
+ }
174
+ }
175
+ }
162
176
  }
163
177
  };
164
178
 
package/src/domain.js CHANGED
@@ -277,7 +277,7 @@ class notDomain extends EventEmitter {
277
277
  async execInModules(methodName, params) {
278
278
  for (let mod of Object.values(this.#modules)) {
279
279
  try {
280
- await executeObjectFunction(mod, "exec", [params]);
280
+ await executeObjectFunction(mod, "exec", [methodName, params]);
281
281
  } catch (e) {
282
282
  this.report(e);
283
283
  }
package/src/headers.js CHANGED
@@ -10,8 +10,6 @@ const DEFAULT_STYLER = (req, res) => {
10
10
  res.set("Cache-Control", "max-age=31536000");
11
11
  };
12
12
 
13
- class notHeadersStyler extends notStyler {}
14
-
15
- notHeadersStyler.setDefault(DEFAULT_STYLER);
13
+ let notHeadersStyler = new notStyler(DEFAULT_STYLER);
16
14
 
17
15
  module.exports = notHeadersStyler;
@@ -12,6 +12,7 @@ module.exports = class InitDBMongoose {
12
12
  const Increment = require("../../../model/increment.js");
13
13
  log.info("Setting up mongoose connection...");
14
14
  const mongoose = require("mongoose");
15
+ mongoose.set("strictQuery", true);
15
16
  mongoose.Promise = global.Promise;
16
17
  await mongoose.connect(
17
18
  conf.uri,
@@ -1,3 +1,5 @@
1
+ const log = require("not-log")(module, "not-node//init//sessions");
2
+
1
3
  module.exports = class InitSessions {
2
4
  /**
3
5
  * Returns constructor of Session driver
@@ -18,7 +20,17 @@ module.exports = class InitSessions {
18
20
 
19
21
  async run({ master, config, options, emit }) {
20
22
  const conf = config.get("session");
21
- const Constructor = InitSessions.getConstructor(conf);
22
- await new Constructor().run({ master, config, options, conf, emit });
23
+ if (conf) {
24
+ const Constructor = InitSessions.getConstructor(conf);
25
+ await new Constructor().run({
26
+ master,
27
+ config,
28
+ options,
29
+ conf,
30
+ emit,
31
+ });
32
+ } else {
33
+ log("no session options");
34
+ }
23
35
  }
24
36
  };
package/src/metas.js CHANGED
@@ -27,8 +27,6 @@ const DEFAULT_STYLER = (req, res) => {
27
27
  };
28
28
  };
29
29
 
30
- class notMetasStyler extends notStyler {}
31
-
32
- notMetasStyler.setDefault(DEFAULT_STYLER);
30
+ const notMetasStyler = new notStyler(DEFAULT_STYLER);
33
31
 
34
32
  module.exports = notMetasStyler;
package/src/styler.js CHANGED
@@ -3,10 +3,14 @@ const DEFAULT_STYLER = () => {
3
3
  };
4
4
 
5
5
  module.exports = class notStyler {
6
- static #stylers = {};
7
- static #defaultStyler = DEFAULT_STYLER;
6
+ #stylers = {};
7
+ #defaultStyler = DEFAULT_STYLER;
8
8
 
9
- static get(stylerName) {
9
+ constructor(defaultStyler = DEFAULT_STYLER) {
10
+ this.setDefault(defaultStyler);
11
+ }
12
+
13
+ get(stylerName) {
10
14
  if (
11
15
  typeof stylerName !== "undefined" &&
12
16
  Object.hasOwn(this.#stylers, stylerName)
@@ -17,7 +21,7 @@ module.exports = class notStyler {
17
21
  }
18
22
  }
19
23
 
20
- static set(stylerName, func) {
24
+ set(stylerName, func) {
21
25
  if (typeof stylerName === "string") {
22
26
  this.#stylers[stylerName] = func;
23
27
  } else {
@@ -26,12 +30,12 @@ module.exports = class notStyler {
26
30
  return this;
27
31
  }
28
32
 
29
- static setDefault(func) {
33
+ setDefault(func) {
30
34
  this.#defaultStyler = func;
31
35
  return this;
32
36
  }
33
37
 
34
- static resetDefault() {
38
+ resetDefault() {
35
39
  this.#defaultStyler = DEFAULT_STYLER;
36
40
  return this;
37
41
  }
package/tmpl/dirs/app.mjs CHANGED
@@ -23,7 +23,7 @@ export default {
23
23
  },
24
24
  "package.json": {
25
25
  tmpl: "app/package.ejs",
26
- args: ["AppName", "appName", "AppDescription"],
26
+ args: ["AppName", "appName", "AppDescription", "modules"],
27
27
  },
28
28
  ".babelrc": "app/.babelrc",
29
29
  ".eslintignore": "app/.eslintignore",
@@ -9,4 +9,8 @@ export default {
9
9
  tmpl: "app/front/rollup.!.ejs",
10
10
  args: [],
11
11
  },
12
+ "build.env.js": {
13
+ tmpl: "app/front/build.env.ejs",
14
+ args: [],
15
+ },
12
16
  };
@@ -1,7 +1,15 @@
1
+
2
+ let replaceSets = {
3
+ development: {},
4
+ production: {},
5
+ stage: {},
6
+ };
7
+
1
8
  let babelOn = () => {
2
9
  return ['production', 'stage', 'development'].indexOf(process.env.NODE_ENV) > -1;
3
10
  };
4
11
 
5
12
  export {
6
- babelOn
13
+ babelOn,
14
+ replaceSets
7
15
  };
@@ -2,12 +2,13 @@
2
2
  "name": "<%- appName %>",
3
3
  "version": "0.0.1",
4
4
  "description": "<%- AppDescription %>",
5
- "main": "app.js",
5
+ "main": "app/server/index.js",
6
6
  "private": true,
7
7
  "engines": {
8
8
  "node": ">14.9"
9
9
  },
10
10
  "scripts": {
11
+ "start":"node ./app/server/index.js",
11
12
  "test": "./node_modules/.bin/mocha --reporter spec ./tests/**.js",
12
13
  "lint": "./node_modules/.bin/eslint ./app/**/**.js ./app/server/**/**/**.js ./app/server/**/**/**/**.js ./app/server/**/**/**/**/**.js --fix",
13
14
  "docs": "./node_modules/.bin/jsdoc -c jsdoc.json",
@@ -29,7 +30,11 @@
29
30
  },
30
31
  "dependencies": {
31
32
  "redis": "*",
32
- "not-node": "*"
33
+ "pug":"*",
34
+ "not-node": "*",
35
+ <% for(let moduleName of modules){ %>"<%- moduleName %>":"*",
36
+ <% } %>
37
+ "dotenv": "*"
33
38
  },
34
39
  "devDependencies": {
35
40
  "@babel/core": "^7.18.9",