@azteam/express 1.2.337 → 1.2.339
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/controller/AdminController.js +3 -3
- package/lib/controller/Controller.js +6 -3
- package/lib/controller/SitemapController.js +18 -11
- package/package.json +2 -2
- package/src/controller/AdminController.js +2 -2
- package/src/controller/Controller.js +7 -2
- package/src/controller/SitemapController.js +15 -6
|
@@ -38,11 +38,11 @@ var ALLOW_FIELDS = ['created_at', 'created_id', 'modified_at', 'modified_id', 'd
|
|
|
38
38
|
var AdminController = /*#__PURE__*/function (_Controller) {
|
|
39
39
|
_inherits(AdminController, _Controller);
|
|
40
40
|
var _super = _createSuper(AdminController);
|
|
41
|
-
function AdminController(
|
|
41
|
+
function AdminController(repository) {
|
|
42
42
|
var _this;
|
|
43
|
-
var options = arguments.length >
|
|
43
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
44
44
|
_classCallCheck(this, AdminController);
|
|
45
|
-
_this = _super.call(this,
|
|
45
|
+
_this = _super.call(this, repository);
|
|
46
46
|
_defineProperty(_assertThisInitialized(_this), "methodGetPaginate", /*#__PURE__*/function () {
|
|
47
47
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, res) {
|
|
48
48
|
var paginateData;
|
|
@@ -4,15 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
|
+
var _pluralize = _interopRequireDefault(require("pluralize"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
7
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
11
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
9
12
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
13
|
var Controller = /*#__PURE__*/function () {
|
|
11
14
|
function Controller() {
|
|
12
|
-
var
|
|
13
|
-
var repository = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
15
|
+
var repository = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
14
16
|
_classCallCheck(this, Controller);
|
|
15
|
-
this.
|
|
17
|
+
this.name = this.constructor.name.replace('Controller', '');
|
|
18
|
+
this.pathName = (0, _pluralize["default"])(_lodash["default"].snakeCase(this.name));
|
|
16
19
|
this.repository = repository;
|
|
17
20
|
}
|
|
18
21
|
_createClass(Controller, [{
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = void 0;
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
9
|
var _path = _interopRequireDefault(require("path"));
|
|
9
10
|
var _util = _interopRequireDefault(require("util"));
|
|
10
11
|
var _Controller2 = _interopRequireDefault(require("./Controller"));
|
|
@@ -22,18 +23,21 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
22
23
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
23
24
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
24
25
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
25
|
-
var TEMPLATE_DIR = _path["default"].resolve('../template/sitemap');
|
|
26
|
+
var TEMPLATE_DIR = _path["default"].resolve(__dirname, '../template/sitemap');
|
|
26
27
|
var SitemapController = /*#__PURE__*/function (_Controller) {
|
|
27
28
|
_inherits(SitemapController, _Controller);
|
|
28
29
|
var _super = _createSuper(SitemapController);
|
|
29
|
-
function SitemapController() {
|
|
30
|
+
function SitemapController(repository) {
|
|
31
|
+
var _this;
|
|
30
32
|
_classCallCheck(this, SitemapController);
|
|
31
|
-
|
|
33
|
+
_this = _super.call(this, repository);
|
|
34
|
+
_this.sitemapName = _lodash["default"].camelCase(_this.name);
|
|
35
|
+
return _this;
|
|
32
36
|
}
|
|
33
37
|
_createClass(SitemapController, [{
|
|
34
38
|
key: "postGetSitemap",
|
|
35
39
|
value: function postGetSitemap() {
|
|
36
|
-
var
|
|
40
|
+
var _this2 = this;
|
|
37
41
|
return {
|
|
38
42
|
path: '/sitemap',
|
|
39
43
|
method: [/*#__PURE__*/function () {
|
|
@@ -49,7 +53,7 @@ var SitemapController = /*#__PURE__*/function (_Controller) {
|
|
|
49
53
|
break;
|
|
50
54
|
}
|
|
51
55
|
_context.next = 4;
|
|
52
|
-
return
|
|
56
|
+
return _this2.repository.find({
|
|
53
57
|
domains: req.rootOrigin,
|
|
54
58
|
metadata_disable: 0
|
|
55
59
|
}, {
|
|
@@ -61,10 +65,13 @@ var SitemapController = /*#__PURE__*/function (_Controller) {
|
|
|
61
65
|
paginateData = _context.sent;
|
|
62
66
|
_templatePath = _path["default"].resolve("".concat(TEMPLATE_DIR, "/list.ejs"));
|
|
63
67
|
data = paginateData.docs.map(function (item) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
if (item.slug !== 'home') {
|
|
69
|
+
return {
|
|
70
|
+
path: _util["default"].format(pattern, item.slug),
|
|
71
|
+
modified_at: item.modified_at
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
68
75
|
});
|
|
69
76
|
return _context.abrupt("return", res.xml(_templatePath, {
|
|
70
77
|
priority: 0.8,
|
|
@@ -73,7 +80,7 @@ var SitemapController = /*#__PURE__*/function (_Controller) {
|
|
|
73
80
|
}));
|
|
74
81
|
case 8:
|
|
75
82
|
_context.next = 10;
|
|
76
|
-
return
|
|
83
|
+
return _this2.repository.count({
|
|
77
84
|
domains: req.rootOrigin,
|
|
78
85
|
metadata_disable: 0
|
|
79
86
|
});
|
|
@@ -82,7 +89,7 @@ var SitemapController = /*#__PURE__*/function (_Controller) {
|
|
|
82
89
|
templatePath = _path["default"].resolve("".concat(TEMPLATE_DIR, "/count.ejs"));
|
|
83
90
|
return _context.abrupt("return", res.xml(templatePath, {
|
|
84
91
|
total: total / 1000,
|
|
85
|
-
name:
|
|
92
|
+
name: _this2.sitemapName,
|
|
86
93
|
domain: req.get('Origin')
|
|
87
94
|
}));
|
|
88
95
|
case 13:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azteam/express",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.339",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "toda <sp.azsolution.net@gmail.com>",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"body-parser": "1.19.0",
|
|
22
22
|
"cookie-parser": "1.4.4",
|
|
23
23
|
"cors": "2.8.4",
|
|
24
|
-
"eiows": "
|
|
24
|
+
"eiows": "4.1.2",
|
|
25
25
|
"ejs": "3.1.6",
|
|
26
26
|
"etag": "1.8.1",
|
|
27
27
|
"express": "4.17.1",
|
|
@@ -22,8 +22,8 @@ const ALLOW_FIELDS = [
|
|
|
22
22
|
];
|
|
23
23
|
|
|
24
24
|
class AdminController extends Controller {
|
|
25
|
-
constructor(
|
|
26
|
-
super(
|
|
25
|
+
constructor(repository, options = {}) {
|
|
26
|
+
super(repository);
|
|
27
27
|
|
|
28
28
|
this.roles = {
|
|
29
29
|
EXEC: null,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import pluralize from 'pluralize';
|
|
3
|
+
|
|
1
4
|
class Controller {
|
|
2
|
-
constructor(
|
|
3
|
-
this.
|
|
5
|
+
constructor(repository = null) {
|
|
6
|
+
this.name = this.constructor.name.replace('Controller', '');
|
|
7
|
+
|
|
8
|
+
this.pathName = pluralize(_.snakeCase(this.name));
|
|
4
9
|
this.repository = repository;
|
|
5
10
|
}
|
|
6
11
|
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
1
2
|
import path from 'path';
|
|
2
3
|
import util from 'util';
|
|
3
4
|
|
|
4
5
|
import Controller from './Controller';
|
|
5
6
|
|
|
6
|
-
const TEMPLATE_DIR = path.resolve('../template/sitemap');
|
|
7
|
+
const TEMPLATE_DIR = path.resolve(__dirname, '../template/sitemap');
|
|
7
8
|
|
|
8
9
|
class SitemapController extends Controller {
|
|
10
|
+
constructor(repository) {
|
|
11
|
+
super(repository);
|
|
12
|
+
this.sitemapName = _.camelCase(this.name);
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
postGetSitemap() {
|
|
10
16
|
return {
|
|
11
17
|
path: '/sitemap',
|
|
@@ -26,10 +32,13 @@ class SitemapController extends Controller {
|
|
|
26
32
|
),
|
|
27
33
|
templatePath = path.resolve(`${TEMPLATE_DIR}/list.ejs`),
|
|
28
34
|
data = paginateData.docs.map((item) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
if (item.slug !== 'home') {
|
|
36
|
+
return {
|
|
37
|
+
path: util.format(pattern, item.slug),
|
|
38
|
+
modified_at: item.modified_at,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
33
42
|
});
|
|
34
43
|
|
|
35
44
|
return res.xml(templatePath, {
|
|
@@ -46,7 +55,7 @@ class SitemapController extends Controller {
|
|
|
46
55
|
|
|
47
56
|
return res.xml(templatePath, {
|
|
48
57
|
total: total / 1000,
|
|
49
|
-
name: this.
|
|
58
|
+
name: this.sitemapName,
|
|
50
59
|
domain: req.get('Origin'),
|
|
51
60
|
});
|
|
52
61
|
},
|