@azteam/express 1.2.437 → 1.2.439
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/lib/Server.js
CHANGED
|
@@ -225,6 +225,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
225
225
|
}
|
|
226
226
|
return this.json(resData);
|
|
227
227
|
};
|
|
228
|
+
app.response.successWithMessage = function (message) {
|
|
229
|
+
var resData = {
|
|
230
|
+
success: true,
|
|
231
|
+
message: message
|
|
232
|
+
};
|
|
233
|
+
return this.json(resData);
|
|
234
|
+
};
|
|
228
235
|
app.response.cleanCookie = function (data) {
|
|
229
236
|
var _this2 = this;
|
|
230
237
|
_lodash["default"].map(data, function (name) {
|
|
@@ -59,35 +59,36 @@ function _default() {
|
|
|
59
59
|
if (options.allowSelectFields) {
|
|
60
60
|
selectFields = req.query.select ? req.query.select.split(',') : [];
|
|
61
61
|
if (selectFields.length > 0) {
|
|
62
|
-
req.paginate.select = _lodash["default"].intersection(options.allowSelectFields,
|
|
62
|
+
req.paginate.select = _lodash["default"].intersection(options.allowSelectFields, _lodash["default"].map(selectFields, function (field) {
|
|
63
|
+
return _lodash["default"].trim(field);
|
|
64
|
+
})).join(' ');
|
|
63
65
|
} else {
|
|
64
66
|
// req.paginate.select = '_id';
|
|
65
67
|
req.paginate.select = options.allowSelectFields.join(' ');
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
delete req.query.select;
|
|
69
|
-
console.log(req.paginate.select);
|
|
70
71
|
if (!req.query.limit) {
|
|
71
|
-
_context.next =
|
|
72
|
+
_context.next = 13;
|
|
72
73
|
break;
|
|
73
74
|
}
|
|
74
75
|
limit = Number(req.query.limit);
|
|
75
76
|
if (!options.allowLimits.includes(limit)) {
|
|
76
|
-
_context.next =
|
|
77
|
+
_context.next = 12;
|
|
77
78
|
break;
|
|
78
79
|
}
|
|
79
80
|
req.paginate.limit = limit;
|
|
80
81
|
delete req.query.limit;
|
|
81
|
-
_context.next =
|
|
82
|
+
_context.next = 13;
|
|
82
83
|
break;
|
|
83
|
-
case
|
|
84
|
+
case 12:
|
|
84
85
|
throw new _error.ErrorException(_error.INVALID, [{
|
|
85
86
|
field: 'limit',
|
|
86
87
|
message: "limit just accept ".concat(options.allowLimits.toString()),
|
|
87
88
|
expected: options.allowLimits,
|
|
88
89
|
actual: limit
|
|
89
90
|
}]);
|
|
90
|
-
case
|
|
91
|
+
case 13:
|
|
91
92
|
req.paginate.page = req.query.page ? Number(req.query.page) : 1;
|
|
92
93
|
if (req.query.sort_by && options.allowSortFields.includes(req.query.sort_by)) {
|
|
93
94
|
req.paginate.sort = _defineProperty({}, req.query.sort_by, req.query.sort_type === 'asc' ? 'asc' : 'desc');
|
|
@@ -96,25 +97,25 @@ function _default() {
|
|
|
96
97
|
delete req.query.sort_type;
|
|
97
98
|
delete req.query.page;
|
|
98
99
|
if (!req.query.autocomplete) {
|
|
99
|
-
_context.next =
|
|
100
|
+
_context.next = 24;
|
|
100
101
|
break;
|
|
101
102
|
}
|
|
102
103
|
if (options.autocompleteField) {
|
|
103
|
-
_context.next =
|
|
104
|
+
_context.next = 21;
|
|
104
105
|
break;
|
|
105
106
|
}
|
|
106
107
|
throw new _error.ErrorException(_error.INVALID, [{
|
|
107
108
|
field: 'autocomplete',
|
|
108
109
|
message: 'Not exists autocomplete field'
|
|
109
110
|
}]);
|
|
110
|
-
case
|
|
111
|
+
case 21:
|
|
111
112
|
req.query = _defineProperty({}, options.autocompleteField, {
|
|
112
113
|
$regex: req.query.autocomplete,
|
|
113
114
|
$options: 'i'
|
|
114
115
|
});
|
|
115
|
-
_context.next =
|
|
116
|
+
_context.next = 26;
|
|
116
117
|
break;
|
|
117
|
-
case
|
|
118
|
+
case 24:
|
|
118
119
|
_lodash["default"].map(req.query, function (value, key) {
|
|
119
120
|
if (key.endsWith('_start')) {
|
|
120
121
|
var newKey = key.replace('_start', '');
|
|
@@ -145,9 +146,9 @@ function _default() {
|
|
|
145
146
|
}
|
|
146
147
|
});
|
|
147
148
|
}
|
|
148
|
-
case
|
|
149
|
+
case 26:
|
|
149
150
|
return _context.abrupt("return", next());
|
|
150
|
-
case
|
|
151
|
+
case 27:
|
|
151
152
|
case "end":
|
|
152
153
|
return _context.stop();
|
|
153
154
|
}
|
package/package.json
CHANGED
package/src/Server.js
CHANGED
|
@@ -213,6 +213,14 @@ class Server {
|
|
|
213
213
|
return this.json(resData);
|
|
214
214
|
};
|
|
215
215
|
|
|
216
|
+
app.response.successWithMessage = function (message) {
|
|
217
|
+
const resData = {
|
|
218
|
+
success: true,
|
|
219
|
+
message,
|
|
220
|
+
};
|
|
221
|
+
return this.json(resData);
|
|
222
|
+
};
|
|
223
|
+
|
|
216
224
|
app.response.cleanCookie = function (data) {
|
|
217
225
|
_.map(data, (name) => {
|
|
218
226
|
this.clearCookie(name, {
|
|
@@ -44,7 +44,10 @@ export default function (opts = {}) {
|
|
|
44
44
|
if (options.allowSelectFields) {
|
|
45
45
|
const selectFields = req.query.select ? req.query.select.split(',') : [];
|
|
46
46
|
if (selectFields.length > 0) {
|
|
47
|
-
req.paginate.select = _.intersection(
|
|
47
|
+
req.paginate.select = _.intersection(
|
|
48
|
+
options.allowSelectFields,
|
|
49
|
+
_.map(selectFields, (field) => _.trim(field))
|
|
50
|
+
).join(' ');
|
|
48
51
|
} else {
|
|
49
52
|
// req.paginate.select = '_id';
|
|
50
53
|
req.paginate.select = options.allowSelectFields.join(' ');
|
|
@@ -52,8 +55,6 @@ export default function (opts = {}) {
|
|
|
52
55
|
}
|
|
53
56
|
delete req.query.select;
|
|
54
57
|
|
|
55
|
-
console.log(req.paginate.select);
|
|
56
|
-
|
|
57
58
|
if (req.query.limit) {
|
|
58
59
|
const limit = Number(req.query.limit);
|
|
59
60
|
|