@azteam/express 1.2.388 → 1.2.390
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
CHANGED
|
@@ -17,6 +17,7 @@ var _morgan = _interopRequireDefault(require("morgan"));
|
|
|
17
17
|
var _cors = _interopRequireDefault(require("cors"));
|
|
18
18
|
var _psl = _interopRequireDefault(require("psl"));
|
|
19
19
|
var _ejs = _interopRequireDefault(require("ejs"));
|
|
20
|
+
var _compression = _interopRequireDefault(require("compression"));
|
|
20
21
|
require("express-async-errors");
|
|
21
22
|
var _error = require("@azteam/error");
|
|
22
23
|
var _util = require("@azteam/util");
|
|
@@ -127,6 +128,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
127
128
|
}));
|
|
128
129
|
app.set('trust proxy', 1);
|
|
129
130
|
app.use((0, _cookieParser["default"])(process.env.SECRET_KEY));
|
|
131
|
+
app.use((0, _compression["default"])());
|
|
130
132
|
app.use((0, _cors["default"])(function (req, callback) {
|
|
131
133
|
var origin = req.header('Origin'),
|
|
132
134
|
authorization = req.header('Authorization'),
|
|
@@ -75,7 +75,6 @@ function _default() {
|
|
|
75
75
|
}]);
|
|
76
76
|
case 11:
|
|
77
77
|
req.paginate.page = req.query.page ? Number(req.query.page) : 1;
|
|
78
|
-
req.paginate.offset = (req.paginate.page - 1) * req.paginate.limit;
|
|
79
78
|
if (req.query.sort_by && options.allowSortFields.includes(req.query.sort_by)) {
|
|
80
79
|
req.paginate.sort = _defineProperty({}, req.query.sort_by, req.query.sort_type === 'asc' ? 'asc' : 'desc');
|
|
81
80
|
}
|
|
@@ -83,25 +82,25 @@ function _default() {
|
|
|
83
82
|
delete req.query.sort_type;
|
|
84
83
|
delete req.query.page;
|
|
85
84
|
if (!req.query.autocomplete) {
|
|
86
|
-
_context.next =
|
|
85
|
+
_context.next = 22;
|
|
87
86
|
break;
|
|
88
87
|
}
|
|
89
88
|
if (options.autocompleteField) {
|
|
90
|
-
_context.next =
|
|
89
|
+
_context.next = 19;
|
|
91
90
|
break;
|
|
92
91
|
}
|
|
93
92
|
throw new _error.ErrorException(_error.INVALID, [{
|
|
94
93
|
field: 'autocomplete',
|
|
95
94
|
message: 'Not exists autocomplete field'
|
|
96
95
|
}]);
|
|
97
|
-
case
|
|
96
|
+
case 19:
|
|
98
97
|
req.query = _defineProperty({}, options.autocompleteField, {
|
|
99
98
|
$regex: req.query.autocomplete,
|
|
100
99
|
$options: 'i'
|
|
101
100
|
});
|
|
102
|
-
_context.next =
|
|
101
|
+
_context.next = 24;
|
|
103
102
|
break;
|
|
104
|
-
case
|
|
103
|
+
case 22:
|
|
105
104
|
_lodash["default"].map(req.query, function (value, key) {
|
|
106
105
|
if (key.endsWith('_start')) {
|
|
107
106
|
var newKey = key.replace('_start', '');
|
|
@@ -133,9 +132,9 @@ function _default() {
|
|
|
133
132
|
}
|
|
134
133
|
});
|
|
135
134
|
}
|
|
136
|
-
case
|
|
135
|
+
case 24:
|
|
137
136
|
return _context.abrupt("return", next());
|
|
138
|
-
case
|
|
137
|
+
case 25:
|
|
139
138
|
case "end":
|
|
140
139
|
return _context.stop();
|
|
141
140
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azteam/express",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.390",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "toda <sp.azsolution.net@gmail.com>",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"@grpc/proto-loader": "0.6.12",
|
|
20
20
|
"@socket.io/redis-adapter": "7.2.0",
|
|
21
21
|
"body-parser": "1.19.0",
|
|
22
|
+
"compression": "1.7.4",
|
|
22
23
|
"cookie-parser": "1.4.4",
|
|
23
24
|
"cors": "2.8.4",
|
|
24
25
|
"eiows": "4.1.2",
|
package/src/Server.js
CHANGED
|
@@ -11,6 +11,7 @@ import morgan from 'morgan';
|
|
|
11
11
|
import cors from 'cors';
|
|
12
12
|
import psl from 'psl';
|
|
13
13
|
import ejs from 'ejs';
|
|
14
|
+
import compression from 'compression';
|
|
14
15
|
import 'express-async-errors';
|
|
15
16
|
import {CORS, errorCatch, ErrorException, NOT_FOUND, UNKNOWN} from '@azteam/error';
|
|
16
17
|
import {omitItem, omitArrayItem} from '@azteam/util';
|
|
@@ -101,7 +102,7 @@ class Server {
|
|
|
101
102
|
app.set('trust proxy', 1);
|
|
102
103
|
|
|
103
104
|
app.use(cookieParser(process.env.SECRET_KEY));
|
|
104
|
-
|
|
105
|
+
app.use(compression());
|
|
105
106
|
app.use(
|
|
106
107
|
cors(function (req, callback) {
|
|
107
108
|
const origin = req.header('Origin'),
|
|
@@ -55,7 +55,6 @@ export default function (options = {}) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
req.paginate.page = req.query.page ? Number(req.query.page) : 1;
|
|
58
|
-
req.paginate.offset = (req.paginate.page - 1) * req.paginate.limit;
|
|
59
58
|
|
|
60
59
|
if (req.query.sort_by && options.allowSortFields.includes(req.query.sort_by)) {
|
|
61
60
|
req.paginate.sort = {
|