@azteam/express 1.2.335 → 1.2.337
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/{AdminController.js → controller/AdminController.js} +3 -3
- package/lib/{Controller.js → controller/Controller.js} +0 -0
- package/lib/controller/SitemapController.js +105 -0
- package/lib/controller/index.js +27 -0
- package/lib/index.js +13 -18
- package/package.json +5 -4
- package/src/{AdminController.js → controller/AdminController.js} +4 -3
- package/src/{Controller.js → controller/Controller.js} +0 -0
- package/src/controller/SitemapController.js +58 -0
- package/src/controller/index.js +3 -0
- package/src/index.js +1 -5
- package/src/template/sitemap/count.ejs +9 -0
- package/src/template/sitemap/home.ejs +13 -0
- package/src/template/sitemap/index.ejs +12 -0
- package/src/template/sitemap/list.ejs +16 -0
|
@@ -8,8 +8,8 @@ exports["default"] = void 0;
|
|
|
8
8
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
9
|
var _error = require("@azteam/error");
|
|
10
10
|
var _validator = require("@azteam/validator");
|
|
11
|
-
var
|
|
12
|
-
var
|
|
11
|
+
var _middleware = require("../middleware");
|
|
12
|
+
var _constant = require("../constant");
|
|
13
13
|
var _Controller2 = _interopRequireDefault(require("./Controller"));
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
15
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
@@ -153,7 +153,7 @@ var AdminController = /*#__PURE__*/function (_Controller) {
|
|
|
153
153
|
while (1) {
|
|
154
154
|
switch (_context5.prev = _context5.next) {
|
|
155
155
|
case 0:
|
|
156
|
-
return _context5.abrupt("return", _this.repository.createByUser(user.id, data
|
|
156
|
+
return _context5.abrupt("return", _this.repository.createByUser(user.id, data));
|
|
157
157
|
case 1:
|
|
158
158
|
case "end":
|
|
159
159
|
return _context5.stop();
|
|
File without changes
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _util = _interopRequireDefault(require("util"));
|
|
10
|
+
var _Controller2 = _interopRequireDefault(require("./Controller"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
13
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
14
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
15
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
16
|
+
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); } }
|
|
17
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
18
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
19
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
20
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
21
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
22
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
23
|
+
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
|
+
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 SitemapController = /*#__PURE__*/function (_Controller) {
|
|
27
|
+
_inherits(SitemapController, _Controller);
|
|
28
|
+
var _super = _createSuper(SitemapController);
|
|
29
|
+
function SitemapController() {
|
|
30
|
+
_classCallCheck(this, SitemapController);
|
|
31
|
+
return _super.apply(this, arguments);
|
|
32
|
+
}
|
|
33
|
+
_createClass(SitemapController, [{
|
|
34
|
+
key: "postGetSitemap",
|
|
35
|
+
value: function postGetSitemap() {
|
|
36
|
+
var _this = this;
|
|
37
|
+
return {
|
|
38
|
+
path: '/sitemap',
|
|
39
|
+
method: [/*#__PURE__*/function () {
|
|
40
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, res) {
|
|
41
|
+
var _req$body, page, pattern, paginateData, _templatePath, data, total, templatePath;
|
|
42
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
43
|
+
while (1) {
|
|
44
|
+
switch (_context.prev = _context.next) {
|
|
45
|
+
case 0:
|
|
46
|
+
_req$body = req.body, page = _req$body.page, pattern = _req$body.pattern;
|
|
47
|
+
if (!page) {
|
|
48
|
+
_context.next = 8;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
_context.next = 4;
|
|
52
|
+
return _this.repository.find({
|
|
53
|
+
domains: req.rootOrigin,
|
|
54
|
+
metadata_disable: 0
|
|
55
|
+
}, {
|
|
56
|
+
select: 'slug modified_at',
|
|
57
|
+
page: page,
|
|
58
|
+
limit: 1000
|
|
59
|
+
});
|
|
60
|
+
case 4:
|
|
61
|
+
paginateData = _context.sent;
|
|
62
|
+
_templatePath = _path["default"].resolve("".concat(TEMPLATE_DIR, "/list.ejs"));
|
|
63
|
+
data = paginateData.docs.map(function (item) {
|
|
64
|
+
return {
|
|
65
|
+
path: _util["default"].format(pattern, item.slug),
|
|
66
|
+
modified_at: item.modified_at
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
return _context.abrupt("return", res.xml(_templatePath, {
|
|
70
|
+
priority: 0.8,
|
|
71
|
+
data: data,
|
|
72
|
+
domain: req.get('Origin')
|
|
73
|
+
}));
|
|
74
|
+
case 8:
|
|
75
|
+
_context.next = 10;
|
|
76
|
+
return _this.repository.count({
|
|
77
|
+
domains: req.rootOrigin,
|
|
78
|
+
metadata_disable: 0
|
|
79
|
+
});
|
|
80
|
+
case 10:
|
|
81
|
+
total = _context.sent;
|
|
82
|
+
templatePath = _path["default"].resolve("".concat(TEMPLATE_DIR, "/count.ejs"));
|
|
83
|
+
return _context.abrupt("return", res.xml(templatePath, {
|
|
84
|
+
total: total / 1000,
|
|
85
|
+
name: _this.name,
|
|
86
|
+
domain: req.get('Origin')
|
|
87
|
+
}));
|
|
88
|
+
case 13:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context.stop();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}, _callee);
|
|
94
|
+
}));
|
|
95
|
+
return function (_x, _x2) {
|
|
96
|
+
return _ref.apply(this, arguments);
|
|
97
|
+
};
|
|
98
|
+
}()]
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}]);
|
|
102
|
+
return SitemapController;
|
|
103
|
+
}(_Controller2["default"]);
|
|
104
|
+
var _default = SitemapController;
|
|
105
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AdminController", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _AdminController["default"];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "Controller", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _Controller["default"];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "SitemapController", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _SitemapController["default"];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _Controller = _interopRequireDefault(require("./Controller"));
|
|
25
|
+
var _AdminController = _interopRequireDefault(require("./AdminController"));
|
|
26
|
+
var _SitemapController = _interopRequireDefault(require("./SitemapController"));
|
|
27
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
package/lib/index.js
CHANGED
|
@@ -3,26 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
Controller: true,
|
|
8
|
-
AdminController: true
|
|
9
|
-
};
|
|
10
|
-
Object.defineProperty(exports, "AdminController", {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function get() {
|
|
13
|
-
return _AdminController["default"];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(exports, "Controller", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function get() {
|
|
19
|
-
return _Controller["default"];
|
|
20
|
-
}
|
|
21
|
-
});
|
|
6
|
+
var _exportNames = {};
|
|
22
7
|
exports["default"] = void 0;
|
|
23
8
|
var _Server = _interopRequireDefault(require("./Server"));
|
|
24
|
-
var _Controller = _interopRequireDefault(require("./Controller"));
|
|
25
|
-
var _AdminController = _interopRequireDefault(require("./AdminController"));
|
|
26
9
|
var _middleware = require("./middleware");
|
|
27
10
|
Object.keys(_middleware).forEach(function (key) {
|
|
28
11
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -35,6 +18,18 @@ Object.keys(_middleware).forEach(function (key) {
|
|
|
35
18
|
}
|
|
36
19
|
});
|
|
37
20
|
});
|
|
21
|
+
var _controller = require("./controller");
|
|
22
|
+
Object.keys(_controller).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
25
|
+
if (key in exports && exports[key] === _controller[key]) return;
|
|
26
|
+
Object.defineProperty(exports, key, {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function get() {
|
|
29
|
+
return _controller[key];
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
38
33
|
var _constant = require("./constant");
|
|
39
34
|
Object.keys(_constant).forEach(function (key) {
|
|
40
35
|
if (key === "default" || key === "__esModule") return;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azteam/express",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.337",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "toda <sp.azsolution.net@gmail.com>",
|
|
4
6
|
"main": "./lib/index.js",
|
|
5
7
|
"module": "./src/index.js",
|
|
6
8
|
"scripts": {
|
|
7
9
|
"build": "babel src --delete-dir-on-start -d lib"
|
|
8
10
|
},
|
|
9
|
-
"author": "toda <sp.azsolution.net@gmail.com>",
|
|
10
|
-
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@azteam/constant": "1.0.6",
|
|
13
13
|
"@azteam/crypto": "1.0.31",
|
|
@@ -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": "3.4.1",
|
|
25
25
|
"ejs": "3.1.6",
|
|
26
26
|
"etag": "1.8.1",
|
|
27
27
|
"express": "4.17.1",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"lodash": "4.17.21",
|
|
33
33
|
"method-override": "3.0.0",
|
|
34
34
|
"morgan": "1.10.0",
|
|
35
|
+
"pluralize": "8.0.0",
|
|
35
36
|
"psl": "1.8.0",
|
|
36
37
|
"socket.io": "4.4.1"
|
|
37
38
|
}
|
|
@@ -2,8 +2,9 @@ import _ from 'lodash';
|
|
|
2
2
|
import {NOT_EXISTS} from '@azteam/error';
|
|
3
3
|
import {rulesId} from '@azteam/validator';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import {adminRoleMiddleware, paginateMiddleware, validateMiddleware} from '../middleware';
|
|
6
|
+
import {REQUEST_TYPE} from '../constant';
|
|
7
|
+
|
|
7
8
|
import Controller from './Controller';
|
|
8
9
|
|
|
9
10
|
const ALLOW_FIELDS = [
|
|
@@ -118,7 +119,7 @@ class AdminController extends Controller {
|
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
methodPostCreate = async (data, user) => {
|
|
121
|
-
return this.repository.createByUser(user.id, data
|
|
122
|
+
return this.repository.createByUser(user.id, data);
|
|
122
123
|
};
|
|
123
124
|
|
|
124
125
|
postCreate() {
|
|
File without changes
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import util from 'util';
|
|
3
|
+
|
|
4
|
+
import Controller from './Controller';
|
|
5
|
+
|
|
6
|
+
const TEMPLATE_DIR = path.resolve('../template/sitemap');
|
|
7
|
+
|
|
8
|
+
class SitemapController extends Controller {
|
|
9
|
+
postGetSitemap() {
|
|
10
|
+
return {
|
|
11
|
+
path: '/sitemap',
|
|
12
|
+
method: [
|
|
13
|
+
async (req, res) => {
|
|
14
|
+
const {page, pattern} = req.body;
|
|
15
|
+
if (page) {
|
|
16
|
+
const paginateData = await this.repository.find(
|
|
17
|
+
{
|
|
18
|
+
domains: req.rootOrigin,
|
|
19
|
+
metadata_disable: 0,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
select: 'slug modified_at',
|
|
23
|
+
page,
|
|
24
|
+
limit: 1000,
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
templatePath = path.resolve(`${TEMPLATE_DIR}/list.ejs`),
|
|
28
|
+
data = paginateData.docs.map((item) => {
|
|
29
|
+
return {
|
|
30
|
+
path: util.format(pattern, item.slug),
|
|
31
|
+
modified_at: item.modified_at,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return res.xml(templatePath, {
|
|
36
|
+
priority: 0.8,
|
|
37
|
+
data,
|
|
38
|
+
domain: req.get('Origin'),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const total = await this.repository.count({
|
|
42
|
+
domains: req.rootOrigin,
|
|
43
|
+
metadata_disable: 0,
|
|
44
|
+
}),
|
|
45
|
+
templatePath = path.resolve(`${TEMPLATE_DIR}/count.ejs`);
|
|
46
|
+
|
|
47
|
+
return res.xml(templatePath, {
|
|
48
|
+
total: total / 1000,
|
|
49
|
+
name: this.name,
|
|
50
|
+
domain: req.get('Origin'),
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default SitemapController;
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import Server from './Server';
|
|
2
2
|
|
|
3
|
-
import Controller from './Controller';
|
|
4
|
-
import AdminController from './AdminController';
|
|
5
|
-
|
|
6
3
|
export * from './middleware';
|
|
4
|
+
export * from './controller';
|
|
7
5
|
export * from './constant';
|
|
8
6
|
|
|
9
|
-
export {Controller, AdminController};
|
|
10
|
-
|
|
11
7
|
export default Server;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
3
|
+
|
|
4
|
+
<% for(var i = 0; i < total; i++) { %>
|
|
5
|
+
<sitemap>
|
|
6
|
+
<loc><%= 'https://' + domain + '/sitemap-' + name + '-' + (i + 1) + '.xml'; %></loc>
|
|
7
|
+
</sitemap>
|
|
8
|
+
<% } %>
|
|
9
|
+
</sitemapindex>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<urlset
|
|
2
|
+
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
4
|
+
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
|
|
5
|
+
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
|
|
6
|
+
<url>
|
|
7
|
+
<loc><%= 'https://' + domain; %></loc>
|
|
8
|
+
<priority>1.0</priority>
|
|
9
|
+
<lastmod><%= new Date().toISOString().split('T')[0]; %></lastmod>
|
|
10
|
+
<changefreq>daily</changefreq>
|
|
11
|
+
</url>
|
|
12
|
+
|
|
13
|
+
</urlset>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
3
|
+
<sitemap>
|
|
4
|
+
<loc><%= 'https://' + domain + '/sitemap-home.xml'; %></loc>
|
|
5
|
+
</sitemap>
|
|
6
|
+
|
|
7
|
+
<% listIndex.forEach(function (item) { %>
|
|
8
|
+
<sitemap>
|
|
9
|
+
<loc><%= 'https://' + domain + '/sitemap-' + item + '.xml'; %></loc>
|
|
10
|
+
</sitemap>
|
|
11
|
+
<% }); %>
|
|
12
|
+
</sitemapindex>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<urlset
|
|
2
|
+
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
4
|
+
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
|
|
5
|
+
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
|
|
6
|
+
<% data.forEach(function (item) { %>
|
|
7
|
+
<% if (item) { %>
|
|
8
|
+
<url>
|
|
9
|
+
<loc><%= 'https://' + domain + item.path; %></loc>
|
|
10
|
+
<priority><%= priority; %></priority>
|
|
11
|
+
<lastmod><%= new Date(item.modified_at * 1000).toISOString().split('T')[0]; %></lastmod>
|
|
12
|
+
<changefreq>daily</changefreq>
|
|
13
|
+
</url>
|
|
14
|
+
<%}%>
|
|
15
|
+
<% }); %>
|
|
16
|
+
</urlset>
|