@resolveio/server-lib 4.5.3 → 4.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "4.5.3",
3
+ "version": "4.5.4",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {
package/server-app.d.ts CHANGED
@@ -14,6 +14,7 @@ export default class ResolveIOMainServer {
14
14
  private _clientDir;
15
15
  private _msgQueue;
16
16
  private _msgQueueRunning;
17
+ private LOGGER;
17
18
  private _resolveioServer;
18
19
  private _subscriptionManager;
19
20
  private _methodManager;
package/server-app.js CHANGED
@@ -64,7 +64,10 @@ var ResolveIOMainServer = /** @class */ (function () {
64
64
  function ResolveIOMainServer(mainServer, serverConfig, clientDir) {
65
65
  this._msgQueue = [];
66
66
  this._msgQueueRunning = false;
67
- console.log('Starting ResolveIO Server');
67
+ this.LOGGER = 'ERROR'; //ERROR / DEBUG
68
+ if (this.LOGGER === 'DEBUG') {
69
+ console.log('Starting ResolveIO Server');
70
+ }
68
71
  this._resolveioServer = mainServer;
69
72
  this._serverConfig = serverConfig;
70
73
  this._clientDir = clientDir;
@@ -76,10 +79,14 @@ var ResolveIOMainServer = /** @class */ (function () {
76
79
  this._app.use(bodyParser.urlencoded({ limit: '5mb', extended: true }));
77
80
  // Set port
78
81
  this._port = process.env.PORT || serverConfig['PORT'];
79
- console.log('Setup ports');
82
+ if (this.LOGGER === 'DEBUG') {
83
+ console.log('Setup ports');
84
+ }
80
85
  // Create http server and websock server
81
86
  this.createServer();
82
- console.log('Create server');
87
+ if (this.LOGGER === 'DEBUG') {
88
+ console.log('Create server');
89
+ }
83
90
  // Set CORS
84
91
  this._app.use(function (req, res, next) {
85
92
  // Website you wish to allow to connect
@@ -96,11 +103,15 @@ var ResolveIOMainServer = /** @class */ (function () {
96
103
  // Pass to next layer of middleware
97
104
  next();
98
105
  });
99
- console.log('Setup cors');
106
+ if (this.LOGGER === 'DEBUG') {
107
+ console.log('Setup cors');
108
+ }
100
109
  // Set up http login route
101
110
  auth_1.setupAuthRoutes(this, this._app, serverConfig);
102
111
  health_1.setupHealthRoutes(this._app, serverConfig);
103
- console.log('Setup express routes');
112
+ if (this.LOGGER === 'DEBUG') {
113
+ console.log('Setup express routes');
114
+ }
104
115
  }
105
116
  ResolveIOMainServer.prototype.getWS = function (id_ws) {
106
117
  var res = null;
@@ -145,7 +156,9 @@ var ResolveIOMainServer = /** @class */ (function () {
145
156
  var infoData, token;
146
157
  var _this = this;
147
158
  return __generator(this, function (_a) {
148
- console.log('Verify Client', info, cb);
159
+ if (this.LOGGER === 'DEBUG') {
160
+ console.log('Verify Client', info, cb);
161
+ }
149
162
  infoData = info.req.headers['sec-websocket-protocol'].split(/,/);
150
163
  if (info.origin !== this._serverConfig['ROOT_URL'] && info.origin !== this._serverConfig['SEC_ROOT_URL'] && info.origin !== this._serverConfig['RESOLVEIO_URL'] && info.origin !== this._serverConfig['RESOLVEIO_SECONDARY_URL']) {
151
164
  cb(false, 401, 'Unauthorized');
@@ -214,14 +227,18 @@ var ResolveIOMainServer = /** @class */ (function () {
214
227
  __setOptions.apply(this, arguments);
215
228
  return this;
216
229
  };
217
- console.log('Start Managers');
230
+ if (this.LOGGER === 'DEBUG') {
231
+ console.log('Start Managers');
232
+ }
218
233
  // Start Managers
219
234
  this._subscriptionManager = new subscription_manager_1.SubscriptionManager(this, this._wss, this._serverConfig);
220
235
  this._methodManager = new method_manager_1.MethodManager(this, this._serverConfig, this._clientDir);
221
236
  this._supportManager = new support_manager_1.SupportManager(this, this._serverConfig, this._clientDir);
222
237
  this._cronManager = new cron_manager_1.CronManager(this);
223
238
  this._queueManager = new queue_method_manager_1.QueueMethodManager(this);
224
- console.log('End Managers');
239
+ if (this.LOGGER === 'DEBUG') {
240
+ console.log('End Managers');
241
+ }
225
242
  this.listen();
226
243
  mongoose.set('useFindAndModify', false);
227
244
  // mongoose.set('useCreateIndexes', true);
@@ -248,7 +265,9 @@ var ResolveIOMainServer = /** @class */ (function () {
248
265
  ws['user_readonly'] = req.user_readonly;
249
266
  ws['id_socket'] = uuid();
250
267
  ws['retryCnt'] = 0;
251
- console.log('Connection from: ' + req.user);
268
+ if (_this.LOGGER === 'DEBUG') {
269
+ console.log('Connection from: ' + req.user);
270
+ }
252
271
  // Use for keeping connection alive (ping/pong)
253
272
  ws['isAlive'] = true;
254
273
  ws.on('pong', function () {
@@ -266,7 +285,9 @@ var ResolveIOMainServer = /** @class */ (function () {
266
285
  var _a, _b, socketData, data, messageDate, messageId, type, subType, pub;
267
286
  var _this = this;
268
287
  return __generator(this, function (_c) {
269
- console.log('Message from: ' + ws['user'], message);
288
+ if (this.LOGGER === 'DEBUG') {
289
+ console.log('Message from: ' + ws['user'], message);
290
+ }
270
291
  socketData = JSON.parse(message, common_1.dateReviver);
271
292
  data = common_2.deepCopy(socketData);
272
293
  if (data[0] === 'ping') {