@azteam/express 1.2.262 → 1.2.264

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": "@azteam/express",
3
- "version": "1.2.262",
3
+ "version": "1.2.264",
4
4
  "main": "src/index.js",
5
5
  "engines": {
6
6
  "node": ">= 12.0.0",
@@ -33,9 +33,9 @@ export default function (cbLoginAPI) {
33
33
  return next();
34
34
  } catch (err) {
35
35
  if (err.name === 'TokenExpiredError') {
36
- return next(new ErrorException(TOKEN_EXPIRED, err));
36
+ throw new ErrorException(TOKEN_EXPIRED, err);
37
37
  }
38
- return next(new ErrorException(TOKEN_FAILED, err));
38
+ throw new ErrorException(TOKEN_FAILED, err);
39
39
  }
40
40
  } else {
41
41
  const data = await cbLoginAPI(token);
@@ -72,7 +72,7 @@ export default function (options = {}) {
72
72
  if (!options.searchFields.includes(key)) {
73
73
  delete req.query[key];
74
74
 
75
- return next(new ErrorException(INVALID, `Not exists search ${key}`));
75
+ // throw new ErrorException(INVALID, `Not exists search ${key}`);
76
76
  }
77
77
  });
78
78
 
@@ -92,10 +92,11 @@ export default function (options = {}) {
92
92
 
93
93
  if (req.query.autocomplete) {
94
94
  if (!options.autocompleteField) {
95
- return next(new ErrorException(INVALID, 'Not exists autocomplete field'));
95
+ throw new ErrorException(INVALID, 'Not exists autocomplete field');
96
96
  }
97
97
 
98
98
  req.query = {
99
+ ...req.query,
99
100
  [options.autocompleteField]: {
100
101
  $regex: req.query.autocomplete,
101
102
  $options: 'i',
@@ -3,14 +3,14 @@ import {ErrorException, PERMISSION, UNAUTHORIZED} from '@azteam/error';
3
3
  export default function (roles = null, minLevel = 1) {
4
4
  return async function (req, res, next) {
5
5
  if (!req.user) {
6
- return next(new ErrorException(UNAUTHORIZED));
6
+ throw new ErrorException(UNAUTHORIZED);
7
7
  }
8
8
  if (req.user.level < minLevel) {
9
- return next(new ErrorException(PERMISSION));
9
+ throw new ErrorException(PERMISSION);
10
10
  }
11
11
  if (!roles || req.user.level === 100 || req.user.roles.some((r) => roles.includes(r))) {
12
12
  return next();
13
13
  }
14
- return next(new ErrorException(PERMISSION));
14
+ throw new ErrorException(PERMISSION);
15
15
  };
16
16
  }
@@ -9,6 +9,6 @@ export default function (mTimeout = 5) {
9
9
  return next();
10
10
  }
11
11
  }
12
- return next(new ErrorException(SIGNATURE_FAILED));
12
+ throw ErrorException(SIGNATURE_FAILED);
13
13
  };
14
14
  }
@@ -51,7 +51,7 @@ export default function (type, rules) {
51
51
  const errors = v.validate(reqData, rules);
52
52
 
53
53
  if (Array.isArray(errors)) {
54
- return next(new ErrorException(INVALID, errors));
54
+ throw ErrorException(INVALID, errors);
55
55
  }
56
56
  return next();
57
57
  };