@azteam/express 1.2.427 → 1.2.430

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.
@@ -331,6 +331,31 @@ var AdminController = /*#__PURE__*/function (_Controller) {
331
331
  return _this;
332
332
  }
333
333
  _createClass(AdminController, [{
334
+ key: "getFilterOption",
335
+ value: function getFilterOption() {
336
+ var _this2 = this;
337
+ return {
338
+ disabled: !this.roles.READ,
339
+ path: '/filter_option',
340
+ method: [(0, _middleware.adminRoleMiddleware)([this.roles.READ], this.roleMiddlewareOptions), /*#__PURE__*/function () {
341
+ var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(req, res) {
342
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
343
+ while (1) switch (_context11.prev = _context11.next) {
344
+ case 0:
345
+ return _context11.abrupt("return", res.success(_this2.paginateOptions));
346
+ case 1:
347
+ case "end":
348
+ return _context11.stop();
349
+ }
350
+ }, _callee11);
351
+ }));
352
+ return function (_x22, _x23) {
353
+ return _ref11.apply(this, arguments);
354
+ };
355
+ }()]
356
+ };
357
+ }
358
+ }, {
334
359
  key: "getAll",
335
360
  value: function getAll() {
336
361
  return {
@@ -378,18 +403,18 @@ var AdminController = /*#__PURE__*/function (_Controller) {
378
403
  }, {
379
404
  key: "beforeCreate",
380
405
  value: function () {
381
- var _beforeCreate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(data) {
382
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
383
- while (1) switch (_context11.prev = _context11.next) {
406
+ var _beforeCreate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(data) {
407
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
408
+ while (1) switch (_context12.prev = _context12.next) {
384
409
  case 0:
385
- return _context11.abrupt("return", data);
410
+ return _context12.abrupt("return", data);
386
411
  case 1:
387
412
  case "end":
388
- return _context11.stop();
413
+ return _context12.stop();
389
414
  }
390
- }, _callee11);
415
+ }, _callee12);
391
416
  }));
392
- function beforeCreate(_x22) {
417
+ function beforeCreate(_x24) {
393
418
  return _beforeCreate.apply(this, arguments);
394
419
  }
395
420
  return beforeCreate;
@@ -397,18 +422,18 @@ var AdminController = /*#__PURE__*/function (_Controller) {
397
422
  }, {
398
423
  key: "afterCreate",
399
424
  value: function () {
400
- var _afterCreate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(item) {
401
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
402
- while (1) switch (_context12.prev = _context12.next) {
425
+ var _afterCreate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(item) {
426
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
427
+ while (1) switch (_context13.prev = _context13.next) {
403
428
  case 0:
404
- return _context12.abrupt("return", item);
429
+ return _context13.abrupt("return", item);
405
430
  case 1:
406
431
  case "end":
407
- return _context12.stop();
432
+ return _context13.stop();
408
433
  }
409
- }, _callee12);
434
+ }, _callee13);
410
435
  }));
411
- function afterCreate(_x23) {
436
+ function afterCreate(_x25) {
412
437
  return _afterCreate.apply(this, arguments);
413
438
  }
414
439
  return afterCreate;
@@ -416,37 +441,37 @@ var AdminController = /*#__PURE__*/function (_Controller) {
416
441
  }, {
417
442
  key: "postCreate",
418
443
  value: function postCreate() {
419
- var _this2 = this;
444
+ var _this3 = this;
420
445
  return {
421
446
  disabled: !this.roles.CREATE,
422
447
  path: '/',
423
448
  method: [(0, _middleware.adminRoleMiddleware)([this.roles.CREATE], this.roleMiddlewareOptions), /*#__PURE__*/function () {
424
- var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(req, res) {
449
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(req, res) {
425
450
  var data, item;
426
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
427
- while (1) switch (_context13.prev = _context13.next) {
451
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
452
+ while (1) switch (_context14.prev = _context14.next) {
428
453
  case 0:
429
- _context13.next = 2;
430
- return _this2.beforeCreate(req.body);
454
+ _context14.next = 2;
455
+ return _this3.beforeCreate(req.body);
431
456
  case 2:
432
- data = _context13.sent;
433
- _context13.next = 5;
434
- return _this2.methodPostCreate(data, req.user);
457
+ data = _context14.sent;
458
+ _context14.next = 5;
459
+ return _this3.methodPostCreate(data, req.user);
435
460
  case 5:
436
- item = _context13.sent;
437
- _context13.next = 8;
438
- return _this2.afterCreate(item);
461
+ item = _context14.sent;
462
+ _context14.next = 8;
463
+ return _this3.afterCreate(item);
439
464
  case 8:
440
- item = _context13.sent;
441
- return _context13.abrupt("return", res.success(item, _this2.guardResponse, _this2.allowResponse));
465
+ item = _context14.sent;
466
+ return _context14.abrupt("return", res.success(item, _this3.guardResponse, _this3.allowResponse));
442
467
  case 10:
443
468
  case "end":
444
- return _context13.stop();
469
+ return _context14.stop();
445
470
  }
446
- }, _callee13);
471
+ }, _callee14);
447
472
  }));
448
- return function (_x24, _x25) {
449
- return _ref11.apply(this, arguments);
473
+ return function (_x26, _x27) {
474
+ return _ref12.apply(this, arguments);
450
475
  };
451
476
  }()]
452
477
  };
@@ -454,18 +479,18 @@ var AdminController = /*#__PURE__*/function (_Controller) {
454
479
  }, {
455
480
  key: "beforeModify",
456
481
  value: function () {
457
- var _beforeModify = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(data) {
458
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
459
- while (1) switch (_context14.prev = _context14.next) {
482
+ var _beforeModify = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(data) {
483
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
484
+ while (1) switch (_context15.prev = _context15.next) {
460
485
  case 0:
461
- return _context14.abrupt("return", data);
486
+ return _context15.abrupt("return", data);
462
487
  case 1:
463
488
  case "end":
464
- return _context14.stop();
489
+ return _context15.stop();
465
490
  }
466
- }, _callee14);
491
+ }, _callee15);
467
492
  }));
468
- function beforeModify(_x26) {
493
+ function beforeModify(_x28) {
469
494
  return _beforeModify.apply(this, arguments);
470
495
  }
471
496
  return beforeModify;
@@ -473,18 +498,18 @@ var AdminController = /*#__PURE__*/function (_Controller) {
473
498
  }, {
474
499
  key: "afterModify",
475
500
  value: function () {
476
- var _afterModify = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(item) {
477
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
478
- while (1) switch (_context15.prev = _context15.next) {
501
+ var _afterModify = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(item) {
502
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
503
+ while (1) switch (_context16.prev = _context16.next) {
479
504
  case 0:
480
- return _context15.abrupt("return", item);
505
+ return _context16.abrupt("return", item);
481
506
  case 1:
482
507
  case "end":
483
- return _context15.stop();
508
+ return _context16.stop();
484
509
  }
485
- }, _callee15);
510
+ }, _callee16);
486
511
  }));
487
- function afterModify(_x27) {
512
+ function afterModify(_x29) {
488
513
  return _afterModify.apply(this, arguments);
489
514
  }
490
515
  return afterModify;
@@ -492,58 +517,13 @@ var AdminController = /*#__PURE__*/function (_Controller) {
492
517
  }, {
493
518
  key: "putModify",
494
519
  value: function putModify() {
495
- var _this3 = this;
496
- return {
497
- disabled: !this.roles.UPDATE,
498
- path: '/:id([a-zA-Z0-9]+)',
499
- method: [(0, _middleware.adminRoleMiddleware)([this.roles.UPDATE], this.roleMiddlewareOptions), (0, _middleware.validateMiddleware)(_constant.REQUEST_TYPE.PARAMS, _validator.rulesId), /*#__PURE__*/function () {
500
- var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(req, res) {
501
- var item, data;
502
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
503
- while (1) switch (_context16.prev = _context16.next) {
504
- case 0:
505
- _context16.next = 2;
506
- return _this3.repository.findOneById(req.params.id);
507
- case 2:
508
- item = _context16.sent;
509
- if (item) {
510
- _context16.next = 5;
511
- break;
512
- }
513
- return _context16.abrupt("return", res.error(_error.NOT_EXISTS));
514
- case 5:
515
- _context16.next = 7;
516
- return _this3.beforeModify(req.body);
517
- case 7:
518
- data = _context16.sent;
519
- item = _this3.methodPutModify(item, data, req.user);
520
- _context16.next = 11;
521
- return _this3.afterModify(item);
522
- case 11:
523
- item = _context16.sent;
524
- return _context16.abrupt("return", res.success(item, _this3.guardResponse, _this3.allowResponse));
525
- case 13:
526
- case "end":
527
- return _context16.stop();
528
- }
529
- }, _callee16);
530
- }));
531
- return function (_x28, _x29) {
532
- return _ref12.apply(this, arguments);
533
- };
534
- }()]
535
- };
536
- }
537
- }, {
538
- key: "putModifyStatusAvailable",
539
- value: function putModifyStatusAvailable() {
540
520
  var _this4 = this;
541
521
  return {
542
522
  disabled: !this.roles.UPDATE,
543
- path: '/available/:id([a-zA-Z0-9]+)',
523
+ path: '/:id([a-zA-Z0-9]+)',
544
524
  method: [(0, _middleware.adminRoleMiddleware)([this.roles.UPDATE], this.roleMiddlewareOptions), (0, _middleware.validateMiddleware)(_constant.REQUEST_TYPE.PARAMS, _validator.rulesId), /*#__PURE__*/function () {
545
525
  var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(req, res) {
546
- var item;
526
+ var item, data;
547
527
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
548
528
  while (1) switch (_context17.prev = _context17.next) {
549
529
  case 0:
@@ -558,14 +538,16 @@ var AdminController = /*#__PURE__*/function (_Controller) {
558
538
  return _context17.abrupt("return", res.error(_error.NOT_EXISTS));
559
539
  case 5:
560
540
  _context17.next = 7;
561
- return item.modifyStatusAvailable(req.user.id);
541
+ return _this4.beforeModify(req.body);
562
542
  case 7:
563
- _context17.next = 9;
543
+ data = _context17.sent;
544
+ item = _this4.methodPutModify(item, data, req.user);
545
+ _context17.next = 11;
564
546
  return _this4.afterModify(item);
565
- case 9:
547
+ case 11:
566
548
  item = _context17.sent;
567
549
  return _context17.abrupt("return", res.success(item, _this4.guardResponse, _this4.allowResponse));
568
- case 11:
550
+ case 13:
569
551
  case "end":
570
552
  return _context17.stop();
571
553
  }
@@ -578,12 +560,12 @@ var AdminController = /*#__PURE__*/function (_Controller) {
578
560
  };
579
561
  }
580
562
  }, {
581
- key: "putModifyStatusUnavailable",
582
- value: function putModifyStatusUnavailable() {
563
+ key: "putModifyStatusAvailable",
564
+ value: function putModifyStatusAvailable() {
583
565
  var _this5 = this;
584
566
  return {
585
567
  disabled: !this.roles.UPDATE,
586
- path: '/unavailable/:id([a-zA-Z0-9]+)',
568
+ path: '/available/:id([a-zA-Z0-9]+)',
587
569
  method: [(0, _middleware.adminRoleMiddleware)([this.roles.UPDATE], this.roleMiddlewareOptions), (0, _middleware.validateMiddleware)(_constant.REQUEST_TYPE.PARAMS, _validator.rulesId), /*#__PURE__*/function () {
588
570
  var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(req, res) {
589
571
  var item;
@@ -601,7 +583,7 @@ var AdminController = /*#__PURE__*/function (_Controller) {
601
583
  return _context18.abrupt("return", res.error(_error.NOT_EXISTS));
602
584
  case 5:
603
585
  _context18.next = 7;
604
- return item.modifyStatusUnavailable(req.body.message, req.user.id);
586
+ return item.modifyStatusAvailable(req.user.id);
605
587
  case 7:
606
588
  _context18.next = 9;
607
589
  return _this5.afterModify(item);
@@ -621,12 +603,12 @@ var AdminController = /*#__PURE__*/function (_Controller) {
621
603
  };
622
604
  }
623
605
  }, {
624
- key: "putModifyStatusWaiting",
625
- value: function putModifyStatusWaiting() {
606
+ key: "putModifyStatusUnavailable",
607
+ value: function putModifyStatusUnavailable() {
626
608
  var _this6 = this;
627
609
  return {
628
610
  disabled: !this.roles.UPDATE,
629
- path: '/waiting/:id([a-zA-Z0-9]+)',
611
+ path: '/unavailable/:id([a-zA-Z0-9]+)',
630
612
  method: [(0, _middleware.adminRoleMiddleware)([this.roles.UPDATE], this.roleMiddlewareOptions), (0, _middleware.validateMiddleware)(_constant.REQUEST_TYPE.PARAMS, _validator.rulesId), /*#__PURE__*/function () {
631
613
  var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(req, res) {
632
614
  var item;
@@ -644,7 +626,7 @@ var AdminController = /*#__PURE__*/function (_Controller) {
644
626
  return _context19.abrupt("return", res.error(_error.NOT_EXISTS));
645
627
  case 5:
646
628
  _context19.next = 7;
647
- return item.modifyStatusWaiting(req.user.id);
629
+ return item.modifyStatusUnavailable(req.body.message, req.user.id);
648
630
  case 7:
649
631
  _context19.next = 9;
650
632
  return _this6.afterModify(item);
@@ -663,21 +645,64 @@ var AdminController = /*#__PURE__*/function (_Controller) {
663
645
  }()]
664
646
  };
665
647
  }
648
+ }, {
649
+ key: "putModifyStatusWaiting",
650
+ value: function putModifyStatusWaiting() {
651
+ var _this7 = this;
652
+ return {
653
+ disabled: !this.roles.UPDATE,
654
+ path: '/waiting/:id([a-zA-Z0-9]+)',
655
+ method: [(0, _middleware.adminRoleMiddleware)([this.roles.UPDATE], this.roleMiddlewareOptions), (0, _middleware.validateMiddleware)(_constant.REQUEST_TYPE.PARAMS, _validator.rulesId), /*#__PURE__*/function () {
656
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(req, res) {
657
+ var item;
658
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
659
+ while (1) switch (_context20.prev = _context20.next) {
660
+ case 0:
661
+ _context20.next = 2;
662
+ return _this7.repository.findOneById(req.params.id);
663
+ case 2:
664
+ item = _context20.sent;
665
+ if (item) {
666
+ _context20.next = 5;
667
+ break;
668
+ }
669
+ return _context20.abrupt("return", res.error(_error.NOT_EXISTS));
670
+ case 5:
671
+ _context20.next = 7;
672
+ return item.modifyStatusWaiting(req.user.id);
673
+ case 7:
674
+ _context20.next = 9;
675
+ return _this7.afterModify(item);
676
+ case 9:
677
+ item = _context20.sent;
678
+ return _context20.abrupt("return", res.success(item, _this7.guardResponse, _this7.allowResponse));
679
+ case 11:
680
+ case "end":
681
+ return _context20.stop();
682
+ }
683
+ }, _callee20);
684
+ }));
685
+ return function (_x36, _x37) {
686
+ return _ref16.apply(this, arguments);
687
+ };
688
+ }()]
689
+ };
690
+ }
666
691
  }, {
667
692
  key: "afterDelete",
668
693
  value: function () {
669
- var _afterDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(item) {
670
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
671
- while (1) switch (_context20.prev = _context20.next) {
694
+ var _afterDelete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(item) {
695
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
696
+ while (1) switch (_context21.prev = _context21.next) {
672
697
  case 0:
673
- return _context20.abrupt("return", item);
698
+ return _context21.abrupt("return", item);
674
699
  case 1:
675
700
  case "end":
676
- return _context20.stop();
701
+ return _context21.stop();
677
702
  }
678
- }, _callee20);
703
+ }, _callee21);
679
704
  }));
680
- function afterDelete(_x36) {
705
+ function afterDelete(_x38) {
681
706
  return _afterDelete.apply(this, arguments);
682
707
  }
683
708
  return afterDelete;
@@ -703,18 +728,18 @@ var AdminController = /*#__PURE__*/function (_Controller) {
703
728
  }, {
704
729
  key: "afterDestroy",
705
730
  value: function () {
706
- var _afterDestroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(item) {
707
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
708
- while (1) switch (_context21.prev = _context21.next) {
731
+ var _afterDestroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(item) {
732
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
733
+ while (1) switch (_context22.prev = _context22.next) {
709
734
  case 0:
710
- return _context21.abrupt("return", item);
735
+ return _context22.abrupt("return", item);
711
736
  case 1:
712
737
  case "end":
713
- return _context21.stop();
738
+ return _context22.stop();
714
739
  }
715
- }, _callee21);
740
+ }, _callee22);
716
741
  }));
717
- function afterDestroy(_x37) {
742
+ function afterDestroy(_x39) {
718
743
  return _afterDestroy.apply(this, arguments);
719
744
  }
720
745
  return afterDestroy;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@azteam/express","version":"1.2.427","license":"MIT","author":"toda <sp.azsolution.net@gmail.com>","main":"./lib/index.js","module":"./src/index.js","scripts":{"prepublishOnly":"babel src --delete-dir-on-start -d lib"},"dependencies":{"@azteam/constant":"1.0.11","@azteam/crypto":"1.0.38","@azteam/error":"1.0.37","@azteam/http-client":"1.0.116","@azteam/util":"1.0.44","@azteam/validator":"1.0.26","@grpc/grpc-js":"1.6.7","@grpc/proto-loader":"0.6.12","@socket.io/redis-adapter":"7.2.0","body-parser":"1.19.0","compression":"1.7.4","cookie-parser":"1.4.4","cors":"2.8.4","eiows":"4.1.2","ejs":"3.1.8","etag":"1.8.1","express":"4.17.1","express-async-errors":"3.1.1","express-rate-limit":"5.1.3","helmet":"3.21.2","jsonwebtoken":"9.0.0","lodash":"4.17.21","method-override":"3.0.0","morgan":"1.10.0","pluralize":"8.0.0","psl":"1.8.0","socket.io":"4.4.1","ua-parser-js":"1.0.32"}}
1
+ {"name":"@azteam/express","version":"1.2.430","license":"MIT","author":"toda <sp.azsolution.net@gmail.com>","main":"./lib/index.js","module":"./src/index.js","scripts":{"prepublishOnly":"babel src --delete-dir-on-start -d lib"},"dependencies":{"@azteam/constant":"1.0.11","@azteam/crypto":"1.0.38","@azteam/error":"1.0.37","@azteam/http-client":"1.0.116","@azteam/util":"1.0.44","@azteam/validator":"1.0.26","@grpc/grpc-js":"1.6.7","@grpc/proto-loader":"0.6.12","@socket.io/redis-adapter":"7.2.0","body-parser":"1.19.0","compression":"1.7.4","cookie-parser":"1.4.4","cors":"2.8.4","eiows":"4.1.2","ejs":"3.1.8","etag":"1.8.1","express":"4.17.1","express-async-errors":"3.1.1","express-rate-limit":"5.1.3","helmet":"3.21.2","jsonwebtoken":"9.0.0","lodash":"4.17.21","method-override":"3.0.0","morgan":"1.10.0","pluralize":"8.0.0","psl":"1.8.0","socket.io":"4.4.1","ua-parser-js":"1.0.32"}}
@@ -76,6 +76,19 @@ class AdminController extends Controller {
76
76
  ];
77
77
  }
78
78
 
79
+ getFilterOption() {
80
+ return {
81
+ disabled: !this.roles.READ,
82
+ path: '/filter_option',
83
+ method: [
84
+ adminRoleMiddleware([this.roles.READ], this.roleMiddlewareOptions),
85
+ async (req, res) => {
86
+ return res.success(this.paginateOptions);
87
+ },
88
+ ],
89
+ };
90
+ }
91
+
79
92
  methodGetAll = async (req, res) => {
80
93
  const data = await this.repository.findAll(req.query, {
81
94
  limit: 2000,