@azteam/express 1.2.377 → 1.2.379

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.
@@ -124,26 +124,26 @@ var SocketServer = /*#__PURE__*/function () {
124
124
  value: function startPort(port) {
125
125
  var _this = this;
126
126
  if (!_lodash["default"].isEmpty(this.controllers)) {
127
- var WHITE_LIST = this.whiteList;
128
- var server = _http["default"].Server((0, _express["default"])());
129
- var io = (0, _socket["default"])(server, {
130
- wsEngine: 'eiows',
131
- perMessageDeflate: {
132
- threshold: 32768
133
- },
134
- cors: {
135
- credentials: true,
136
- origin: function origin(_origin, callback) {
137
- if (!_origin || !WHITE_LIST.length || WHITE_LIST.some(function (re) {
138
- return _origin.endsWith(re);
139
- })) {
140
- callback(null, true);
141
- } else {
142
- callback(new Error("".concat(_origin, " Not allowed by CORS")));
127
+ var WHITE_LIST = this.whiteList,
128
+ server = _http["default"].Server((0, _express["default"])()),
129
+ io = (0, _socket["default"])(server, {
130
+ wsEngine: 'eiows',
131
+ perMessageDeflate: {
132
+ threshold: 32768
133
+ },
134
+ cors: {
135
+ credentials: true,
136
+ origin: function origin(_origin, callback) {
137
+ if (!_origin || !WHITE_LIST.length || WHITE_LIST.some(function (re) {
138
+ return _origin.endsWith(re);
139
+ })) {
140
+ callback(null, true);
141
+ } else {
142
+ callback(new Error("".concat(_origin, " Not allowed by CORS")));
143
+ }
143
144
  }
144
145
  }
145
- }
146
- });
146
+ });
147
147
  if (this.options.redisConfig) {
148
148
  io.adapter((0, _redisAdapter.createAdapter)(this.options.redisConfig));
149
149
  }
@@ -152,8 +152,8 @@ var SocketServer = /*#__PURE__*/function () {
152
152
  var controller = obj.controller;
153
153
  _lodash["default"].map(controller, function (item, key) {
154
154
  item.path = obj.version.startsWith('v') ? "/".concat(obj.version).concat(item.path) : item.path;
155
- var nsp = io.of(item.path);
156
- var middlewares = [].concat(_toConsumableArray(_this.middlewares), _toConsumableArray(item.middlewares || []));
155
+ var nsp = io.of(item.path),
156
+ middlewares = [].concat(_toConsumableArray(_this.middlewares), _toConsumableArray(item.middlewares || []));
157
157
  nsp.use(wrap(_bodyParser["default"].urlencoded({
158
158
  limit: '5mb',
159
159
  extended: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azteam/express",
3
- "version": "1.2.377",
3
+ "version": "1.2.379",
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.32",
15
15
  "@azteam/http-client": "1.0.109",
16
16
  "@azteam/util": "1.0.36",
17
- "@azteam/validator": "1.0.15",
17
+ "@azteam/validator": "1.0.17",
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",
@@ -73,26 +73,24 @@ class SocketServer {
73
73
 
74
74
  startPort(port) {
75
75
  if (!_.isEmpty(this.controllers)) {
76
- const WHITE_LIST = this.whiteList;
77
-
78
- const server = http.Server(express());
79
-
80
- const io = socketIO(server, {
81
- wsEngine: 'eiows',
82
- perMessageDeflate: {
83
- threshold: 32768,
84
- },
85
- cors: {
86
- credentials: true,
87
- origin(origin, callback) {
88
- if (!origin || !WHITE_LIST.length || WHITE_LIST.some((re) => origin.endsWith(re))) {
89
- callback(null, true);
90
- } else {
91
- callback(new Error(`${origin} Not allowed by CORS`));
92
- }
76
+ const WHITE_LIST = this.whiteList,
77
+ server = http.Server(express()),
78
+ io = socketIO(server, {
79
+ wsEngine: 'eiows',
80
+ perMessageDeflate: {
81
+ threshold: 32768,
93
82
  },
94
- },
95
- });
83
+ cors: {
84
+ credentials: true,
85
+ origin(origin, callback) {
86
+ if (!origin || !WHITE_LIST.length || WHITE_LIST.some((re) => origin.endsWith(re))) {
87
+ callback(null, true);
88
+ } else {
89
+ callback(new Error(`${origin} Not allowed by CORS`));
90
+ }
91
+ },
92
+ },
93
+ });
96
94
 
97
95
  if (this.options.redisConfig) {
98
96
  io.adapter(createAdapter(this.options.redisConfig));
@@ -105,9 +103,8 @@ class SocketServer {
105
103
  _.map(controller, (item, key) => {
106
104
  item.path = obj.version.startsWith('v') ? `/${obj.version}${item.path}` : item.path;
107
105
 
108
- const nsp = io.of(item.path);
109
-
110
- const middlewares = [...this.middlewares, ...(item.middlewares || [])];
106
+ const nsp = io.of(item.path),
107
+ middlewares = [...this.middlewares, ...(item.middlewares || [])];
111
108
 
112
109
  nsp.use(wrap(bodyParser.urlencoded({limit: '5mb', extended: true})));
113
110
  nsp.use(wrap(bodyParser.json({limit: '5mb'})));