@azteam/express 1.2.437 → 1.2.438

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.
@@ -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, selectFields).join(' ');
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 = 14;
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 = 13;
77
+ _context.next = 12;
77
78
  break;
78
79
  }
79
80
  req.paginate.limit = limit;
80
81
  delete req.query.limit;
81
- _context.next = 14;
82
+ _context.next = 13;
82
83
  break;
83
- case 13:
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 14:
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 = 25;
100
+ _context.next = 24;
100
101
  break;
101
102
  }
102
103
  if (options.autocompleteField) {
103
- _context.next = 22;
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 22:
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 = 27;
116
+ _context.next = 26;
116
117
  break;
117
- case 25:
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 27:
149
+ case 26:
149
150
  return _context.abrupt("return", next());
150
- case 28:
151
+ case 27:
151
152
  case "end":
152
153
  return _context.stop();
153
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azteam/express",
3
- "version": "1.2.437",
3
+ "version": "1.2.438",
4
4
  "license": "MIT",
5
5
  "author": "toda <sp.azsolution.net@gmail.com>",
6
6
  "main": "./lib/index.js",
@@ -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(options.allowSelectFields, selectFields).join(' ');
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