not-node 6.2.15 → 6.2.17
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 +1 -1
- package/src/common.js +55 -15
- package/src/form/env_extractors/query.js +6 -2
package/package.json
CHANGED
package/src/common.js
CHANGED
|
@@ -156,21 +156,21 @@ module.exports.executeFunctionAsAsync = executeFunctionAsAsync;
|
|
|
156
156
|
**/
|
|
157
157
|
module.exports.executeObjectFunction = async (obj, name, params) => {
|
|
158
158
|
if (obj) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (name.indexOf(".") > -1) {
|
|
162
|
+
const proc =
|
|
163
|
+
typeof obj == "object" ? notPath.get(":" + name, obj) : obj[name];
|
|
164
|
+
if (!proc) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
return await executeFunctionAsAsync(proc.bind(obj), params);
|
|
168
|
+
} else {
|
|
169
|
+
if (obj[name] && isFunc(obj[name])) {
|
|
170
|
+
if (isAsync(obj[name])) {
|
|
171
|
+
return await obj[name](...params);
|
|
172
|
+
} else {
|
|
173
|
+
return obj[name](...params);
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
}
|
|
@@ -205,6 +205,22 @@ module.exports.tryFile = (filePath) => {
|
|
|
205
205
|
}
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Asynchronously check file existence and if it's really a file
|
|
210
|
+
* @param {string} filePath full path to file
|
|
211
|
+
* @return {Promise<boolean>} true if path exists and it's a file
|
|
212
|
+
**/
|
|
213
|
+
module.exports.tryFileAsync = (filePath) => {
|
|
214
|
+
return new Promise((resolve, reject) => {
|
|
215
|
+
try {
|
|
216
|
+
const stat = fs.lstatSync(filePath);
|
|
217
|
+
resolve(stat && stat.isFile());
|
|
218
|
+
} catch (e) {
|
|
219
|
+
reject(false);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
|
|
208
224
|
/**
|
|
209
225
|
* Trying to parse input to JSON or returns def
|
|
210
226
|
* @param {string} input string to be parsed
|
|
@@ -219,6 +235,30 @@ module.exports.tryParse = (input, def = undefined) => {
|
|
|
219
235
|
}
|
|
220
236
|
};
|
|
221
237
|
|
|
238
|
+
/**
|
|
239
|
+
* Trying to asynchronously parse input to JSON or returns def
|
|
240
|
+
* @param {string} input string to be parsed
|
|
241
|
+
* @param {any} def what to return if parse failed, default undefined
|
|
242
|
+
* @return {Promise<Object>} JSON
|
|
243
|
+
**/
|
|
244
|
+
module.exports.tryParseAsync = (
|
|
245
|
+
input,
|
|
246
|
+
def = undefined,
|
|
247
|
+
throwOnException = false
|
|
248
|
+
) => {
|
|
249
|
+
return new Promise((resolve, reject) => {
|
|
250
|
+
try {
|
|
251
|
+
resolve(JSON.parse(input));
|
|
252
|
+
} catch (e) {
|
|
253
|
+
if (throwOnException && !def) {
|
|
254
|
+
reject(e);
|
|
255
|
+
} else {
|
|
256
|
+
resolve(def);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
|
|
222
262
|
/**
|
|
223
263
|
* Generates paths object for module/index.js files based on content and relative
|
|
224
264
|
* path
|
|
@@ -9,11 +9,15 @@ module.exports = (form, req) => {
|
|
|
9
9
|
`${MODULE_NAME}//${MODEL_NAME}`
|
|
10
10
|
);
|
|
11
11
|
if (thisSchema) {
|
|
12
|
-
|
|
12
|
+
let skip, size;
|
|
13
|
+
const pager = notFilter.pager.process(req), //skip,size
|
|
13
14
|
sorter = notFilter.sorter.process(req, thisSchema),
|
|
14
15
|
search = notFilter.search.process(req, thisSchema);
|
|
15
16
|
let filter = notFilter.filter.process(req, thisSchema);
|
|
16
|
-
|
|
17
|
+
if (pager) {
|
|
18
|
+
skip = pager.skip;
|
|
19
|
+
size = pager.size;
|
|
20
|
+
}
|
|
17
21
|
return {
|
|
18
22
|
name: "query",
|
|
19
23
|
value: { skip, size, sorter, search, filter },
|