@azteam/express 1.2.267 → 1.2.269
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/Server.js +1 -1
- package/src/middleware/paginateMiddleware.js +36 -41
- package/src/validate.js +0 -2
package/package.json
CHANGED
package/src/Server.js
CHANGED
|
@@ -210,7 +210,7 @@ class Server {
|
|
|
210
210
|
let responseGuard = guard;
|
|
211
211
|
const responseAllows = allow;
|
|
212
212
|
if (_.isArray(guard)) {
|
|
213
|
-
responseGuard = [...guard, '__v', '_id', 'deleted_at', 'updated_at', 'created_id', 'modified_id'];
|
|
213
|
+
responseGuard = [...guard, '__v', '_id', 'deleted_at', 'updated_at', 'created_id', 'modified_id', 'resource'];
|
|
214
214
|
if (resType === RES_TYPE.ARRAY || resType === RES_TYPE.DOCS) {
|
|
215
215
|
responseGuard = [...guard, 'metadata_disable', 'metadata_keywords', 'metadata_description', 'metadata_image_url'];
|
|
216
216
|
}
|
|
@@ -52,58 +52,53 @@ export default function (options = {}) {
|
|
|
52
52
|
delete req.query.sort_type;
|
|
53
53
|
delete req.query.page;
|
|
54
54
|
|
|
55
|
-
_.map(req.query, (value, key) => {
|
|
56
|
-
if (key.endsWith('_start')) {
|
|
57
|
-
const newKey = key.replace('_start', '');
|
|
58
|
-
|
|
59
|
-
req.query[newKey] = {
|
|
60
|
-
...req.query[newKey],
|
|
61
|
-
$gte: value,
|
|
62
|
-
};
|
|
63
|
-
} else if (key.endsWith('_end')) {
|
|
64
|
-
const newKey = key.replace('_end', '');
|
|
65
|
-
|
|
66
|
-
req.query[newKey] = {
|
|
67
|
-
...req.query[newKey],
|
|
68
|
-
$lte: value,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (!options.searchFields.includes(key)) {
|
|
73
|
-
delete req.query[key];
|
|
74
|
-
|
|
75
|
-
// throw new ErrorException(INVALID, `Not exists search ${key}`);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
if (req.query.keywords) {
|
|
80
|
-
const arrKeywords = _.words(req.query.keywords);
|
|
81
|
-
const keywords = `"${arrKeywords.join('" "')}"`;
|
|
82
|
-
|
|
83
|
-
delete req.query.keywords;
|
|
84
|
-
|
|
85
|
-
req.query = {
|
|
86
|
-
...req.query,
|
|
87
|
-
$text: {
|
|
88
|
-
$search: keywords,
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
55
|
if (req.query.autocomplete) {
|
|
94
56
|
if (!options.autocompleteField) {
|
|
95
57
|
throw new ErrorException(INVALID, 'Not exists autocomplete field');
|
|
96
58
|
}
|
|
97
59
|
|
|
98
60
|
req.query = {
|
|
99
|
-
...req.query,
|
|
100
61
|
[options.autocompleteField]: {
|
|
101
62
|
$regex: req.query.autocomplete,
|
|
102
63
|
$options: 'i',
|
|
103
64
|
},
|
|
104
65
|
};
|
|
105
|
-
|
|
106
|
-
|
|
66
|
+
} else {
|
|
67
|
+
_.map(req.query, (value, key) => {
|
|
68
|
+
if (key.endsWith('_start')) {
|
|
69
|
+
const newKey = key.replace('_start', '');
|
|
70
|
+
|
|
71
|
+
req.query[newKey] = {
|
|
72
|
+
...req.query[newKey],
|
|
73
|
+
$gte: value,
|
|
74
|
+
};
|
|
75
|
+
} else if (key.endsWith('_end')) {
|
|
76
|
+
const newKey = key.replace('_end', '');
|
|
77
|
+
|
|
78
|
+
req.query[newKey] = {
|
|
79
|
+
...req.query[newKey],
|
|
80
|
+
$lte: value,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!options.searchFields.includes(key)) {
|
|
85
|
+
throw new ErrorException(INVALID, `Not exists search ${key}`);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
if (req.query.keywords) {
|
|
90
|
+
const arrKeywords = _.words(req.query.keywords);
|
|
91
|
+
const keywords = `"${arrKeywords.join('" "')}"`;
|
|
92
|
+
|
|
93
|
+
delete req.query.keywords;
|
|
94
|
+
|
|
95
|
+
req.query = {
|
|
96
|
+
...req.query,
|
|
97
|
+
$text: {
|
|
98
|
+
$search: keywords,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
107
102
|
}
|
|
108
103
|
|
|
109
104
|
return next();
|
package/src/validate.js
CHANGED