not-node 6.3.27 → 6.3.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "6.3.27",
3
+ "version": "6.3.29",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -87,9 +87,8 @@ module.exports = ({
87
87
 
88
88
  const createDefaultForm = function ({ actionName, MODULE_NAME }) {
89
89
  const FIELDS = [
90
- ["activeUser", "not-node//requiredObject"],
90
+ ["identity", "not-node//requiredObject"],
91
91
  ["data", `${MODULE_NAME}//_data`],
92
- ["ip", "not-node//ip"],
93
92
  ];
94
93
  const FORM_NAME = `${MODULE_NAME}:${firstLetterToUpper(
95
94
  actionName
@@ -117,16 +116,19 @@ module.exports = ({
117
116
  };
118
117
 
119
118
  const beforeDecorator = async (req, res, next) => {
119
+ Log?.debug(
120
+ req.method,
121
+ req.originalUrl,
122
+ JSON.stringify(req.notRouteData, null, 4)
123
+ );
120
124
  const actionName = req.notRouteData.actionName;
121
125
  const trimmedActionName = actionName.replace("_", "");
122
126
  const FormValidator = getForm(trimmedActionName);
123
- if (FormValidator) {
124
- const prepared = await FormValidator.run(req, res, next);
125
- checkAccessRules(trimmedActionName, prepared);
126
- return prepared;
127
- } else {
128
- return {};
129
- }
127
+ const prepared = FormValidator
128
+ ? await FormValidator.run(req, res, next)
129
+ : {};
130
+ await checkAccessRules(trimmedActionName, prepared, req);
131
+ return prepared;
130
132
  };
131
133
 
132
134
  const afterDecorator = (req, res, next, result) => {
@@ -8,7 +8,7 @@ const FIELDS = [
8
8
  ["identity", "not-node//requiredObject"],
9
9
  ];
10
10
 
11
- module.exports = ({ MODULE_NAME, MODEL_NAME, actionName }) => {
11
+ module.exports = ({ MODULE_NAME, MODEL_NAME, actionName = "getByID" }) => {
12
12
  const FORM_NAME = `${MODULE_NAME}:${MODEL_NAME}:${firstLetterToUpper(
13
13
  actionName
14
14
  )}Form`;
@@ -8,7 +8,7 @@ const FIELDS = [
8
8
  ["identity", "not-node//requiredObject"],
9
9
  ];
10
10
 
11
- module.exports = ({ MODULE_NAME, MODEL_NAME, actionName }) => {
11
+ module.exports = ({ MODULE_NAME, MODEL_NAME, actionName = "getById" }) => {
12
12
  const FORM_NAME = `${MODULE_NAME}:${MODEL_NAME}:${firstLetterToUpper(
13
13
  actionName
14
14
  )}Form`;
@@ -17,7 +17,7 @@ const FIELDS = [
17
17
  * @param {string} params.actionName //action name
18
18
  * @return {Form} form class definition
19
19
  */
20
- const FactoryFormList = ({ MODULE_NAME, MODEL_NAME, actionName }) => {
20
+ const FactoryFormList = ({ MODULE_NAME, MODEL_NAME, actionName = "list" }) => {
21
21
  const FORM_NAME = `${MODULE_NAME}:${MODEL_NAME}:${firstLetterToUpper(
22
22
  actionName
23
23
  )}Form`;
@@ -17,7 +17,11 @@ const FIELDS = [
17
17
  * @param {string} params.actionName //action name
18
18
  * @return {Form} form class definition
19
19
  */
20
- const FactoryFormListAndCount = ({ MODULE_NAME, MODEL_NAME, actionName }) => {
20
+ const FactoryFormListAndCount = ({
21
+ MODULE_NAME,
22
+ MODEL_NAME,
23
+ actionName = "listAndCount",
24
+ }) => {
21
25
  const FORM_NAME = `${MODULE_NAME}:${MODEL_NAME}:${firstLetterToUpper(
22
26
  actionName
23
27
  )}Form`;
@@ -48,7 +48,7 @@ module.exports = class InitRoutes {
48
48
  message: err.message,
49
49
  });
50
50
  } else {
51
- log.error("Unknown error:", err);
51
+ log?.error("Unknown error:", err);
52
52
  res.status(500).json({
53
53
  status: "error",
54
54
  });
@@ -58,7 +58,7 @@ module.exports = class InitRoutes {
58
58
  }
59
59
 
60
60
  async run({ master, config, options }) {
61
- log.info("Setting up routes...");
61
+ log?.info("Setting up routes...");
62
62
  //pages rendering
63
63
  await master.getApp().execInModules("registerPagesRoutes", master);
64
64
  //api first
@@ -133,14 +133,16 @@ class notRoute {
133
133
  );
134
134
  }
135
135
  obsoleteRuleFields(rule, req.originalUrl);
136
- let actionName = this.selectActionName(rule);
137
- let mod = this.notApp.getModule(this.moduleName);
136
+ const actionName = this.selectActionName(rule);
137
+ const mod = this.notApp.getModule(this.moduleName);
138
138
  if (!mod) {
139
139
  return next(
140
140
  new HttpError(
141
141
  404,
142
142
  [
143
143
  "module not found",
144
+ req.method,
145
+ req.originalUrl,
144
146
  this.moduleName,
145
147
  this.routeName,
146
148
  actionName,
@@ -148,7 +150,7 @@ class notRoute {
148
150
  )
149
151
  );
150
152
  }
151
- let modRoute = mod.getRoute(this.routeName);
153
+ const modRoute = mod.getRoute(this.routeName);
152
154
  this.setRequestRouteData(
153
155
  req,
154
156
  this.createRequestRouteData(actionName, rule)
@@ -165,6 +167,8 @@ class notRoute {
165
167
  404,
166
168
  [
167
169
  "route not found",
170
+ req.method,
171
+ req.originalUrl,
168
172
  this.moduleName,
169
173
  this.routeName,
170
174
  actionName,