@azteam/express 1.2.290 → 1.2.291

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.
@@ -341,17 +341,6 @@ var AdminController = /*#__PURE__*/function (_Controller) {
341
341
  _this.paginateOptions = options.paginateOptions || {};
342
342
  _this.guardResponse = options.guardResponse || [];
343
343
  _this.allowResponse = options.allowResponse ? [].concat(_toConsumableArray(options.allowResponse), ALLOW_FIELDS) : ALLOW_FIELDS;
344
- _this.rulesCreate = _objectSpread(_objectSpread({}, options.rulesCreate), {}, {
345
- priority: (0, _validator.schemaNumber)(true),
346
- status: (0, _validator.schemaEnum)([0, 1, 2], true)
347
- });
348
- _this.rulesModify = _objectSpread({
349
- isForceModify: (0, _validator.schemaBoolean)(true)
350
- }, _lodash["default"].mapValues(_this.rulesCreate, function (obj) {
351
- return _objectSpread(_objectSpread({}, obj), {}, {
352
- optional: true
353
- });
354
- }));
355
344
  if (_this.paginateOptions) {
356
345
  _this.paginateOptions.allowSearchFields = [].concat(_toConsumableArray(_this.paginateOptions.allowSearchFields), ['status', 'created_at_start', 'created_at_end', 'modified_at_start', 'modified_at_end']);
357
346
  _this.paginateOptions.allowSortFields = [].concat(_toConsumableArray(_this.paginateOptions.allowSortFields), ['created_at', 'modified_at', 'status']);
@@ -442,7 +431,7 @@ var AdminController = /*#__PURE__*/function (_Controller) {
442
431
  return {
443
432
  disabled: !this.roles.CREATE,
444
433
  path: '/',
445
- method: [(0, _middleware.adminRoleMiddleware)([this.roles.CREATE]), (0, _middleware.validateMiddleware)(_constant.REQUEST_TYPE.BODY, this.rulesCreate), this.methodPostCreatePublic]
434
+ method: [(0, _middleware.adminRoleMiddleware)([this.roles.CREATE]), this.methodPostCreatePublic]
446
435
  };
447
436
  }
448
437
  }, {
@@ -493,7 +482,7 @@ var AdminController = /*#__PURE__*/function (_Controller) {
493
482
  return {
494
483
  disabled: !this.roles.UPDATE,
495
484
  path: '/:id',
496
- method: [(0, _middleware.adminRoleMiddleware)([this.roles.UPDATE]), (0, _middleware.validateMiddleware)(_constant.REQUEST_TYPE.PARAMS, _validator.rulesId), (0, _middleware.validateMiddleware)(_constant.REQUEST_TYPE.BODY, this.rulesModify), this.methodPutModifyPublic]
485
+ method: [(0, _middleware.adminRoleMiddleware)([this.roles.UPDATE]), (0, _middleware.validateMiddleware)(_constant.REQUEST_TYPE.PARAMS, _validator.rulesId), this.methodPutModifyPublic]
497
486
  };
498
487
  }
499
488
  }, {
@@ -17,7 +17,7 @@ function _default(type, rules) {
17
17
  while (1) {
18
18
  switch (_context.prev = _context.next) {
19
19
  case 0:
20
- (0, _validator["default"])(req[type], rules, true);
20
+ (0, _validator["default"])(req[type], rules);
21
21
  return _context.abrupt("return", next());
22
22
  case 2:
23
23
  case "end":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azteam/express",
3
- "version": "1.2.290",
3
+ "version": "1.2.291",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./src/index.js",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  import _ from 'lodash';
2
2
  import {NOT_EXISTS} from '@azteam/error';
3
- import {rulesId, schemaBoolean, schemaEnum, schemaNumber} from '@azteam/validator';
3
+ import {rulesId} from '@azteam/validator';
4
4
 
5
5
  import {REQUEST_TYPE} from './constant';
6
6
  import {adminRoleMiddleware, paginateMiddleware, validateMiddleware} from './middleware';
@@ -41,19 +41,6 @@ class AdminController extends Controller {
41
41
  this.guardResponse = options.guardResponse || [];
42
42
  this.allowResponse = options.allowResponse ? [...options.allowResponse, ...ALLOW_FIELDS] : ALLOW_FIELDS;
43
43
 
44
- this.rulesCreate = {
45
- ...options.rulesCreate,
46
- priority: schemaNumber(true),
47
- status: schemaEnum([0, 1, 2], true),
48
- };
49
-
50
- this.rulesModify = {
51
- isForceModify: schemaBoolean(true),
52
- ..._.mapValues(this.rulesCreate, function (obj) {
53
- return {...obj, optional: true};
54
- }),
55
- };
56
-
57
44
  if (this.paginateOptions) {
58
45
  this.paginateOptions.allowSearchFields = [
59
46
  ...this.paginateOptions.allowSearchFields,
@@ -143,7 +130,7 @@ class AdminController extends Controller {
143
130
  return {
144
131
  disabled: !this.roles.CREATE,
145
132
  path: '/',
146
- method: [adminRoleMiddleware([this.roles.CREATE]), validateMiddleware(REQUEST_TYPE.BODY, this.rulesCreate), this.methodPostCreatePublic],
133
+ method: [adminRoleMiddleware([this.roles.CREATE]), this.methodPostCreatePublic],
147
134
  };
148
135
  }
149
136
 
@@ -174,12 +161,7 @@ class AdminController extends Controller {
174
161
  return {
175
162
  disabled: !this.roles.UPDATE,
176
163
  path: '/:id',
177
- method: [
178
- adminRoleMiddleware([this.roles.UPDATE]),
179
- validateMiddleware(REQUEST_TYPE.PARAMS, rulesId),
180
- validateMiddleware(REQUEST_TYPE.BODY, this.rulesModify),
181
- this.methodPutModifyPublic,
182
- ],
164
+ method: [adminRoleMiddleware([this.roles.UPDATE]), validateMiddleware(REQUEST_TYPE.PARAMS, rulesId), this.methodPutModifyPublic],
183
165
  };
184
166
  }
185
167
 
@@ -2,7 +2,7 @@ import validator from '@azteam/validator';
2
2
 
3
3
  export default function (type, rules) {
4
4
  return async function (req, res, next) {
5
- validator(req[type], rules, true);
5
+ validator(req[type], rules);
6
6
 
7
7
  return next();
8
8
  };