@azteam/express 1.2.403 → 1.2.405
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/Server.js +0 -1
- package/lib/controller/index.js +0 -7
- package/lib/middleware/roleMiddleware.js +1 -1
- package/package.json +2 -2
- package/src/Server.js +1 -2
- package/src/controller/index.js +0 -1
- package/src/middleware/roleMiddleware.js +2 -2
- package/lib/controller/SitemapController.js +0 -125
- package/src/controller/SitemapController.js +0 -76
- package/template/sitemap/count.ejs +0 -9
- package/template/sitemap/home.ejs +0 -7
- package/template/sitemap/index.ejs +0 -13
- package/template/sitemap/list.ejs +0 -22
package/lib/Server.js
CHANGED
|
@@ -13,7 +13,6 @@ var _helmet = _interopRequireDefault(require("helmet"));
|
|
|
13
13
|
var _methodOverride = _interopRequireDefault(require("method-override"));
|
|
14
14
|
var _bodyParser = _interopRequireDefault(require("body-parser"));
|
|
15
15
|
var _cookieParser = _interopRequireDefault(require("cookie-parser"));
|
|
16
|
-
var _uaParserJs = _interopRequireDefault(require("ua-parser-js"));
|
|
17
16
|
var _morgan = _interopRequireDefault(require("morgan"));
|
|
18
17
|
var _cors = _interopRequireDefault(require("cors"));
|
|
19
18
|
var _psl = _interopRequireDefault(require("psl"));
|
package/lib/controller/index.js
CHANGED
|
@@ -15,13 +15,6 @@ Object.defineProperty(exports, "Controller", {
|
|
|
15
15
|
return _Controller["default"];
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "SitemapController", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _SitemapController["default"];
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
18
|
var _Controller = _interopRequireDefault(require("./Controller"));
|
|
25
19
|
var _AdminController = _interopRequireDefault(require("./AdminController"));
|
|
26
|
-
var _SitemapController = _interopRequireDefault(require("./SitemapController"));
|
|
27
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azteam/express",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.405",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "toda <sp.azsolution.net@gmail.com>",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@azteam/error": "1.0.33",
|
|
15
15
|
"@azteam/http-client": "1.0.112",
|
|
16
16
|
"@azteam/util": "1.0.36",
|
|
17
|
-
"@azteam/validator": "1.0.
|
|
17
|
+
"@azteam/validator": "1.0.19",
|
|
18
18
|
"@grpc/grpc-js": "1.6.7",
|
|
19
19
|
"@grpc/proto-loader": "0.6.12",
|
|
20
20
|
"@socket.io/redis-adapter": "7.2.0",
|
package/src/Server.js
CHANGED
|
@@ -7,7 +7,6 @@ import helmet from 'helmet';
|
|
|
7
7
|
import methodOverride from 'method-override';
|
|
8
8
|
import bodyParser from 'body-parser';
|
|
9
9
|
import cookieParser from 'cookie-parser';
|
|
10
|
-
import UAParser from 'ua-parser-js';
|
|
11
10
|
import morgan from 'morgan';
|
|
12
11
|
import cors from 'cors';
|
|
13
12
|
import psl from 'psl';
|
|
@@ -15,7 +14,7 @@ import ejs from 'ejs';
|
|
|
15
14
|
import compression from 'compression';
|
|
16
15
|
import 'express-async-errors';
|
|
17
16
|
import {CORS, errorCatch, ErrorException, NOT_FOUND, UNKNOWN} from '@azteam/error';
|
|
18
|
-
import {
|
|
17
|
+
import {omitArrayItem, omitItem} from '@azteam/util';
|
|
19
18
|
|
|
20
19
|
const RES_TYPE = {
|
|
21
20
|
ARRAY: 'ARRAY',
|
package/src/controller/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import jwt from 'jsonwebtoken';
|
|
2
2
|
import {USER_LEVEL} from '@azteam/constant';
|
|
3
3
|
import HttpClient from '@azteam/http-client';
|
|
4
|
-
import {ErrorException, PERMISSION,
|
|
4
|
+
import {ErrorException, PERMISSION, TOKEN_EXPIRED, TOKEN_FAILED, UNAUTHORIZED} from '@azteam/error';
|
|
5
5
|
|
|
6
6
|
function systemLogin(userData = null) {
|
|
7
7
|
let user = {};
|
|
@@ -59,7 +59,7 @@ export default function (roles = null, minLevel = USER_LEVEL.USER, options = {})
|
|
|
59
59
|
const client = new HttpClient({
|
|
60
60
|
timeout: 20000,
|
|
61
61
|
headers: {
|
|
62
|
-
'User-Agent': '
|
|
62
|
+
'User-Agent': req.header('User-Agent'),
|
|
63
63
|
},
|
|
64
64
|
}),
|
|
65
65
|
response = await client.get(apiURL);
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
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 _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); }
|
|
13
|
-
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, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $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 defineProperty(generator, "_invoke", { value: makeInvokeMethod(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; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(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); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), 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, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), 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 (val) { var object = Object(val), 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; }
|
|
14
|
-
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); } }
|
|
15
|
-
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); }); }; }
|
|
16
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
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, _toPropertyKey(descriptor.key), descriptor); } }
|
|
18
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
19
|
-
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); }
|
|
20
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
21
|
-
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); }; }
|
|
22
|
-
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); }
|
|
23
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
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; } }
|
|
25
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
26
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
27
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
28
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
29
|
-
var TEMPLATE_DIR = _path["default"].join(__dirname, '..', '..', 'template/sitemap');
|
|
30
|
-
var SitemapController = /*#__PURE__*/function (_Controller) {
|
|
31
|
-
_inherits(SitemapController, _Controller);
|
|
32
|
-
var _super = _createSuper(SitemapController);
|
|
33
|
-
function SitemapController(repository) {
|
|
34
|
-
var _this;
|
|
35
|
-
var pathName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
36
|
-
_classCallCheck(this, SitemapController);
|
|
37
|
-
_this = _super.call(this, repository, pathName);
|
|
38
|
-
_defineProperty(_assertThisInitialized(_this), "select", 'slug modified_at');
|
|
39
|
-
_this.sitemapName = _lodash["default"].camelCase(_this.name);
|
|
40
|
-
return _this;
|
|
41
|
-
}
|
|
42
|
-
_createClass(SitemapController, [{
|
|
43
|
-
key: "customPath",
|
|
44
|
-
value: function customPath(item, pattern) {
|
|
45
|
-
return _util["default"].format(pattern, item.slug);
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
key: "postGetSitemap",
|
|
49
|
-
value: function postGetSitemap() {
|
|
50
|
-
var _this2 = this;
|
|
51
|
-
return {
|
|
52
|
-
path: '/sitemap',
|
|
53
|
-
method: [/*#__PURE__*/function () {
|
|
54
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, res) {
|
|
55
|
-
var _req$body, page, pattern, paginateData, _templatePath, data, total, templatePath;
|
|
56
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
57
|
-
while (1) {
|
|
58
|
-
switch (_context.prev = _context.next) {
|
|
59
|
-
case 0:
|
|
60
|
-
_req$body = req.body, page = _req$body.page, pattern = _req$body.pattern;
|
|
61
|
-
if (!page) {
|
|
62
|
-
_context.next = 8;
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
_context.next = 4;
|
|
66
|
-
return _this2.repository.find({
|
|
67
|
-
domains: req.rootOrigin,
|
|
68
|
-
metadata_disable: 0
|
|
69
|
-
}, {
|
|
70
|
-
sort: {
|
|
71
|
-
created_at: 'asc'
|
|
72
|
-
},
|
|
73
|
-
select: _this2.select,
|
|
74
|
-
page: page,
|
|
75
|
-
limit: 1000
|
|
76
|
-
});
|
|
77
|
-
case 4:
|
|
78
|
-
paginateData = _context.sent;
|
|
79
|
-
_templatePath = _path["default"].resolve("".concat(TEMPLATE_DIR, "/list.ejs"));
|
|
80
|
-
data = paginateData.docs.map(function (item) {
|
|
81
|
-
if (item.slug !== 'home') {
|
|
82
|
-
return {
|
|
83
|
-
path: _this2.customPath(item, pattern),
|
|
84
|
-
modified_at: item.modified_at,
|
|
85
|
-
thumb: item.thumb
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return null;
|
|
89
|
-
});
|
|
90
|
-
return _context.abrupt("return", res.xml(_templatePath, {
|
|
91
|
-
data: data,
|
|
92
|
-
domain: req.get('Origin')
|
|
93
|
-
}));
|
|
94
|
-
case 8:
|
|
95
|
-
_context.next = 10;
|
|
96
|
-
return _this2.repository.count({
|
|
97
|
-
domains: req.rootOrigin,
|
|
98
|
-
metadata_disable: 0
|
|
99
|
-
});
|
|
100
|
-
case 10:
|
|
101
|
-
total = _context.sent;
|
|
102
|
-
templatePath = _path["default"].resolve("".concat(TEMPLATE_DIR, "/count.ejs"));
|
|
103
|
-
return _context.abrupt("return", res.xml(templatePath, {
|
|
104
|
-
total: total / 1000,
|
|
105
|
-
name: _this2.sitemapName,
|
|
106
|
-
domain: req.get('Origin')
|
|
107
|
-
}));
|
|
108
|
-
case 13:
|
|
109
|
-
case "end":
|
|
110
|
-
return _context.stop();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}, _callee);
|
|
114
|
-
}));
|
|
115
|
-
return function (_x, _x2) {
|
|
116
|
-
return _ref.apply(this, arguments);
|
|
117
|
-
};
|
|
118
|
-
}()]
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
}]);
|
|
122
|
-
return SitemapController;
|
|
123
|
-
}(_Controller2["default"]);
|
|
124
|
-
var _default = SitemapController;
|
|
125
|
-
exports["default"] = _default;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import util from 'util';
|
|
4
|
-
|
|
5
|
-
import Controller from './Controller';
|
|
6
|
-
|
|
7
|
-
const TEMPLATE_DIR = path.join(__dirname, '..', '..', 'template/sitemap');
|
|
8
|
-
|
|
9
|
-
class SitemapController extends Controller {
|
|
10
|
-
select = 'slug modified_at';
|
|
11
|
-
|
|
12
|
-
constructor(repository, pathName = null) {
|
|
13
|
-
super(repository, pathName);
|
|
14
|
-
this.sitemapName = _.camelCase(this.name);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
customPath(item, pattern) {
|
|
18
|
-
return util.format(pattern, item.slug);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
postGetSitemap() {
|
|
22
|
-
return {
|
|
23
|
-
path: '/sitemap',
|
|
24
|
-
method: [
|
|
25
|
-
async (req, res) => {
|
|
26
|
-
const {page, pattern} = req.body;
|
|
27
|
-
if (page) {
|
|
28
|
-
const paginateData = await this.repository.find(
|
|
29
|
-
{
|
|
30
|
-
domains: req.rootOrigin,
|
|
31
|
-
metadata_disable: 0,
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
sort: {
|
|
35
|
-
created_at: 'asc',
|
|
36
|
-
},
|
|
37
|
-
select: this.select,
|
|
38
|
-
page,
|
|
39
|
-
limit: 1000,
|
|
40
|
-
}
|
|
41
|
-
),
|
|
42
|
-
templatePath = path.resolve(`${TEMPLATE_DIR}/list.ejs`),
|
|
43
|
-
data = paginateData.docs.map((item) => {
|
|
44
|
-
if (item.slug !== 'home') {
|
|
45
|
-
return {
|
|
46
|
-
path: this.customPath(item, pattern),
|
|
47
|
-
modified_at: item.modified_at,
|
|
48
|
-
thumb: item.thumb,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
return res.xml(templatePath, {
|
|
55
|
-
data,
|
|
56
|
-
domain: req.get('Origin'),
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
const total = await this.repository.count({
|
|
60
|
-
domains: req.rootOrigin,
|
|
61
|
-
metadata_disable: 0,
|
|
62
|
-
}),
|
|
63
|
-
templatePath = path.resolve(`${TEMPLATE_DIR}/count.ejs`);
|
|
64
|
-
|
|
65
|
-
return res.xml(templatePath, {
|
|
66
|
-
total: total / 1000,
|
|
67
|
-
name: this.sitemapName,
|
|
68
|
-
domain: req.get('Origin'),
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export default SitemapController;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
3
|
-
<% for(var i = 0; i < total; i++) { %>
|
|
4
|
-
<sitemap>
|
|
5
|
-
<loc><%= 'https://' + domain + '/sitemap-' + name + '-' + (i + 1) + '.xml'; %></loc>
|
|
6
|
-
<lastmod><%= new Date().toISOString().split('T')[0]; %></lastmod>
|
|
7
|
-
</sitemap>
|
|
8
|
-
<% } %>
|
|
9
|
-
</sitemapindex>
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
<lastmod><%= new Date().toISOString().split('T')[0]; %></lastmod>
|
|
11
|
-
</sitemap>
|
|
12
|
-
<% }); %>
|
|
13
|
-
</sitemapindex>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
3
|
-
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
|
|
4
|
-
<% data.forEach(function (item) { %>
|
|
5
|
-
<% if (item) { %>
|
|
6
|
-
<url>
|
|
7
|
-
<loc><%= "https://" + domain + item.path; %></loc>
|
|
8
|
-
<% if (item.thumb) { %>
|
|
9
|
-
<image:image>
|
|
10
|
-
<image:loc><%= item.thumb %></image:loc>
|
|
11
|
-
</image:image>
|
|
12
|
-
<% } %>
|
|
13
|
-
|
|
14
|
-
<% if (item.modified_at) { %>
|
|
15
|
-
<lastmod><%= new Date(item.modified_at * 1000).toISOString().split('T')[0]; %></lastmod>
|
|
16
|
-
<% } else { %>
|
|
17
|
-
<lastmod><%= new Date().toISOString().split('T')[0]; %></lastmod>
|
|
18
|
-
<% } %>
|
|
19
|
-
</url>
|
|
20
|
-
<% } %>
|
|
21
|
-
<% }); %>
|
|
22
|
-
</urlset>
|