@resolveio/server-lib 9.7.16 → 9.7.18

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.
@@ -70,7 +70,7 @@ var MonitorManager = /** @class */ (function () {
70
70
  });
71
71
  this._monitorAgent.on('cpu', function (data) { return __awaiter(_this, void 0, void 0, function () {
72
72
  return __generator(this, function (_a) {
73
- if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {
73
+ if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {
74
74
  monitor_cpu_collection_1.MonitorCPUs.create({
75
75
  _id: mongo_manager_1.objectIdHexString(),
76
76
  __v: 0,
@@ -98,7 +98,7 @@ var MonitorManager = /** @class */ (function () {
98
98
  }); });
99
99
  this._monitorAgent.on('memory', function (data) { return __awaiter(_this, void 0, void 0, function () {
100
100
  return __generator(this, function (_a) {
101
- if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {
101
+ if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {
102
102
  monitor_memory_collection_1.MonitorMemorys.create({
103
103
  _id: mongo_manager_1.objectIdHexString(),
104
104
  __v: 0,
@@ -134,7 +134,7 @@ var MonitorManager = /** @class */ (function () {
134
134
  }); });
135
135
  this._monitorAgent.on('https', function (data) { return __awaiter(_this, void 0, void 0, function () {
136
136
  return __generator(this, function (_a) {
137
- if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {
137
+ if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {
138
138
  monitor_https_inbound_collection_1.MonitorHTTPSInbounds.create({
139
139
  _id: mongo_manager_1.objectIdHexString(),
140
140
  __v: 0,
@@ -168,7 +168,7 @@ var MonitorManager = /** @class */ (function () {
168
168
  }); });
169
169
  this._monitorAgent.on('https-outbound', function (data) { return __awaiter(_this, void 0, void 0, function () {
170
170
  return __generator(this, function (_a) {
171
- if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {
171
+ if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {
172
172
  monitor_https_outbound_collection_1.MonitorHTTPSOutbounds.create({
173
173
  _id: mongo_manager_1.objectIdHexString(),
174
174
  __v: 0,
@@ -206,7 +206,7 @@ var MonitorManager = /** @class */ (function () {
206
206
  }); });
207
207
  this._monitorAgent.on('mongo', function (data) { return __awaiter(_this, void 0, void 0, function () {
208
208
  return __generator(this, function (_a) {
209
- if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {
209
+ if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {
210
210
  if (!data.collection.startsWith('monitor-')) {
211
211
  monitor_mongo_collection_1.MonitorMongos.create({
212
212
  _id: mongo_manager_1.objectIdHexString(),
@@ -238,8 +238,16 @@ var MonitorManager = /** @class */ (function () {
238
238
  return [2 /*return*/];
239
239
  });
240
240
  }); });
241
+ this._monitorAgent.on('eventloop', function (data) { return __awaiter(_this, void 0, void 0, function () {
242
+ return __generator(this, function (_a) {
243
+ if (this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {
244
+ console.log(JSON.stringify(data, null, 2));
245
+ }
246
+ return [2 /*return*/];
247
+ });
248
+ }); });
241
249
  // this._monitorAgent.on('socket', async (data) => {
242
- // if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {
250
+ // if (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {
243
251
  // }
244
252
  // else {
245
253
  // const response = await post('/api/monitor/socket', {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/managers/monitor.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2BAA6B;AAC7B,gFAAoE;AAC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AO,CAAC,GAAG,CAAC,GAAC,CAAC,CAAC;yBACf;;;wBAjBoC,CAAC,EAAE,CAAA;;;6BAsBvC,OAAO,CAAC,MAAM,EAAd,yBAAc;;;;wBAEC,qBAAM,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,EAAA;;wBAA9C,QAAQ,GAAG,SAAmC;;;;wBAGpD,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,EAAE;4BACzH,uBAAe,CAAC,aAAa,EAAE,CAAC,gBAAgB,EAAE,CAAC,SAAS,CAAC,mBAAmB,EAAE,yCAAyC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;4BAEzJ,OAAO,CAAC,GAAG,CAAC,GAAC,CAAC,CAAC;yBACf;;;wBAML,IAAI,CAAC,cAAc,EAAE,CAAC;;;;aACtB,EAAE,KAAK,CAAC,CAAC;IACX,CAAC;IACF,qBAAC;AAAD,CAzQA,AAyQC,IAAA;AAzQY,wCAAc","file":"monitor.manager.js","sourcesContent":["import ResolveIOMainServer from '../server-app';\nimport * as bent from 'bent';\nimport { MonitorCPUs } from '../collections/monitor-cpu.collection';\nimport { MonitorMemorys } from '../collections/monitor-memory.collection';\nimport { MonitorHTTPSInbounds } from '../collections/monitor-https-inbound.collection';\nimport { MonitorHTTPSOutbounds } from '../collections/monitor-https-outbound.collection';\nimport { MonitorMongos } from '../collections/monitor-mongo.collection';\nimport { ResolveIOServer } from '../index';\nimport { deepCopy } from '../util/common';\nimport { objectIdHexString } from './mongo.manager';\n\nexport class MonitorManager {\n\tprivate _mainServer: ResolveIOMainServer;\n\tprivate _monitorAgent;\n\tprivate _serverConfig;\n\tprivate _instanceHostname = '';\n\tprivate _monitorData = [];\n\n\tconstructor(mainServer, monitorAgent, serverConfig) {\n\t\tthis._mainServer = mainServer;\n\t\tthis._monitorAgent = monitorAgent;\n\t\tthis._serverConfig = serverConfig;\n\n\t\tthis.setupEvents();\n\t\tthis.setupEventLoop();\n\t}\n\n\tsetupEvents() {\t\t\n\t\tthis._monitorAgent.on('initialized', (env) => {\n\t\t\tenv = this._monitorAgent.getEnvironment();\n\t\t\tfor (let entry in env) {\n\t\t\t\tconsole.log(entry + ':' + env[entry]);\n\t\t\t\tif (entry === 'environment.HOSTNAME') {\n\t\t\t\t\tthis._instanceHostname = env[entry].replace('ip-', '').replace(/-/g, '.');\n\t\t\t\t}\n\t\t\t};\n\t\t});\n\t\t\n\t\tthis._monitorAgent.on('cpu', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\tMonitorCPUs.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tapp: data.process,\n\t\t\t\t\tsystem: data.system\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'cpu',\n\t\t\t\t\t\tapp: data.process,\n\t\t\t\t\t\tsystem: data.system\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('memory', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\tMonitorMemorys.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tphysical_total: data.physical_total,\n\t\t\t\t\tphysical_used: data.physical_used,\n\t\t\t\t\tphysical_free: data.physical_free,\n\t\t\t\t\tvirtual: data.virtual,\n\t\t\t\t\tprivate: data.private,\n\t\t\t\t\tphysical: data.physical\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'memory',\n\t\t\t\t\t\tphysical_total: data.physical_total,\n\t\t\t\t\t\tphysical_used: data.physical_used,\n\t\t\t\t\t\tphysical_free: data.physical_free,\n\t\t\t\t\t\tvirtual: data.virtual,\n\t\t\t\t\t\tprivate: data.private,\n\t\t\t\t\t\tphysical: data.physical\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('https', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\tMonitorHTTPSInbounds.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tmethod: data.method,\n\t\t\t\t\turl: data.url,\n\t\t\t\t\tduration: data.duration,\n\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\trequestHeader: data.requestHeader\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'https-inbound',\n\t\t\t\t\t\tmethod: data.method,\n\t\t\t\t\t\turl: data.url,\n\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\t\trequestHeader: data.requestHeader\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('https-outbound', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\tMonitorHTTPSOutbounds.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tmethod: data.method,\n\t\t\t\t\turl: data.url,\n\t\t\t\t\tduration: data.duration,\n\t\t\t\t\tstatus: data.status,\n\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\trequestHeaders: data.requestHeaders\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (!data.url.startsWith('https://backend.resolveio.com/api/monitor/')) {\n\t\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\t\ttype: 'https-outbound',\n\t\t\t\t\t\t\tmethod: data.method,\n\t\t\t\t\t\t\turl: data.url,\n\t\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\t\tstatus: data.status,\n\t\t\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\t\t\trequestHeaders: data.requestHeaders\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('mongo', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\tif (!data.collection.startsWith('monitor-')) {\n\t\t\t\t\tMonitorMongos.create({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\tmethod: data.method,\n\t\t\t\t\t\tdoc_collection: data.collection,\n\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\tquery: data.query\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'mongo',\n\t\t\t\t\t\tmethod: data.method,\n\t\t\t\t\t\tdoc_collection: data.collection,\n\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\tquery: data.query\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// this._monitorAgent.on('socket', async (data) => {\n\t\t// \tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\n\t\t// \t}\n\t\t// \telse {\n\t\t// \t\tconst response = await post('/api/monitor/socket', {\n\t\t// \t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t// \t\t\tdate: new Date(data.time),\n\t\t\t\t\t\n\t\t// \t\t});\n\t\t// \t}\n\t\t// });\n\t}\n\n\tsetupEventLoop() {\n\t\tsetTimeout(async () => {\n\t\t\tif (this._monitorData.length) {\n\t\t\t\tconst post = bent('https://backend.resolveio.com', 'POST', 'json', 200);\n\n\t\t\t\tlet monitorData = deepCopy(this._monitorData);\n\t\t\t\tthis._monitorData = [];\n\n\t\t\t\tlet size = JSON.stringify(monitorData).replace(/[\\[\\]\\,\\\"]/g,'').length * 8;\n\n\t\t\t\tif (size < 45000000) { // 50 MB size limit\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst response = await post('/api/monitor', monitorData);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\tif (e.statusCode !== 500 && e.statusCode !== 501 && e.statusCode !== 502 && e.statusCode !== 503 && e.statusCode !== 504) {\n\t\t\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'RESOLVEIO MONITOR HTTP - Error Detected', JSON.stringify(e, null, 2));\n\n\t\t\t\t\t\t\tconsole.log(e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet tmpData = [];\n\t\t\t\t\tfor (let i = 0; i < monitorData.length; i++) {\n\t\t\t\t\t\ttmpData.push(monitorData[i]);\n\t\t\t\t\t\tsize = JSON.stringify(tmpData).replace(/[\\[\\]\\,\\\"]/g,'').length * 8;\n\n\t\t\t\t\t\tif (size > 45000000) {\n\t\t\t\t\t\t\ttmpData.pop();\n\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst response = await post('/api/monitor', tmpData);\n\n\t\t\t\t\t\t\t\ttmpData = [monitorData[i]];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\t\tif (e.statusCode !== 500 && e.statusCode !== 501 && e.statusCode !== 502 && e.statusCode !== 503 && e.statusCode !== 504) {\n\t\t\t\t\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'RESOLVEIO MONITOR HTTP - Error Detected', JSON.stringify(e, null, 2));\n\t\t\n\t\t\t\t\t\t\t\t\tconsole.log(e);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (tmpData.length) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst response = await post('/api/monitor', tmpData);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\tif (e.statusCode !== 500 && e.statusCode !== 501 && e.statusCode !== 502 && e.statusCode !== 503 && e.statusCode !== 504) {\n\t\t\t\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'RESOLVEIO MONITOR HTTP - Error Detected', JSON.stringify(e, null, 2));\n\t\n\t\t\t\t\t\t\t\tconsole.log(e);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.setupEventLoop();\n\t\t}, 60000);\n\t}\n}"]}
1
+ {"version":3,"sources":["../../src/managers/monitor.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2BAA6B;AAC7B,gFAAoE;AACpE,sFAA0E;AAC1E,oGAAuF;AACvF,sGAAyF;AACzF,oFAAwE;AACxE,kCAA2C;AAC3C,yCAA0C;AAC1C,iDAAoD;AAEpD;IAOC,wBAAY,UAAU,EAAE,YAAY,EAAE,YAAY;QAH1C,sBAAiB,GAAG,EAAE,CAAC;QACvB,iBAAY,GAAG,EAAE,CAAC;QAGzB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAElC,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,cAAc,EAAE,CAAC;IACvB,CAAC;IAED,oCAAW,GAAX;QAAA,iBA6LC;QA5LA,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,aAAa,EAAE,UAAC,GAAG;YACxC,GAAG,GAAG,KAAI,CAAC,aAAa,CAAC,c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C,GAAC,CAAC,CAAC;yBACf;;;wBAjBoC,CAAC,EAAE,CAAA;;;6BAsBvC,OAAO,CAAC,MAAM,EAAd,yBAAc;;;;wBAEC,qBAAM,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,EAAA;;wBAA9C,QAAQ,GAAG,SAAmC;;;;wBAGpD,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,IAAI,GAAC,CAAC,UAAU,KAAK,GAAG,EAAE;4BACzH,uBAAe,CAAC,aAAa,EAAE,CAAC,gBAAgB,EAAE,CAAC,SAAS,CAAC,mBAAmB,EAAE,yCAAyC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;4BAEzJ,OAAO,CAAC,GAAG,CAAC,GAAC,CAAC,CAAC;yBACf;;;wBAML,IAAI,CAAC,cAAc,EAAE,CAAC;;;;aACtB,EAAE,KAAK,CAAC,CAAC;IACX,CAAC;IACF,qBAAC;AAAD,CA/QA,AA+QC,IAAA;AA/QY,wCAAc","file":"monitor.manager.js","sourcesContent":["import ResolveIOMainServer from '../server-app';\nimport * as bent from 'bent';\nimport { MonitorCPUs } from '../collections/monitor-cpu.collection';\nimport { MonitorMemorys } from '../collections/monitor-memory.collection';\nimport { MonitorHTTPSInbounds } from '../collections/monitor-https-inbound.collection';\nimport { MonitorHTTPSOutbounds } from '../collections/monitor-https-outbound.collection';\nimport { MonitorMongos } from '../collections/monitor-mongo.collection';\nimport { ResolveIOServer } from '../index';\nimport { deepCopy } from '../util/common';\nimport { objectIdHexString } from './mongo.manager';\n\nexport class MonitorManager {\n\tprivate _mainServer: ResolveIOMainServer;\n\tprivate _monitorAgent;\n\tprivate _serverConfig;\n\tprivate _instanceHostname = '';\n\tprivate _monitorData = [];\n\n\tconstructor(mainServer, monitorAgent, serverConfig) {\n\t\tthis._mainServer = mainServer;\n\t\tthis._monitorAgent = monitorAgent;\n\t\tthis._serverConfig = serverConfig;\n\n\t\tthis.setupEvents();\n\t\tthis.setupEventLoop();\n\t}\n\n\tsetupEvents() {\t\t\n\t\tthis._monitorAgent.on('initialized', (env) => {\n\t\t\tenv = this._monitorAgent.getEnvironment();\n\t\t\tfor (let entry in env) {\n\t\t\t\tconsole.log(entry + ':' + env[entry]);\n\t\t\t\tif (entry === 'environment.HOSTNAME') {\n\t\t\t\t\tthis._instanceHostname = env[entry].replace('ip-', '').replace(/-/g, '.');\n\t\t\t\t}\n\t\t\t};\n\t\t});\n\t\t\n\t\tthis._monitorAgent.on('cpu', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tMonitorCPUs.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tapp: data.process,\n\t\t\t\t\tsystem: data.system\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'cpu',\n\t\t\t\t\t\tapp: data.process,\n\t\t\t\t\t\tsystem: data.system\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('memory', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tMonitorMemorys.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tphysical_total: data.physical_total,\n\t\t\t\t\tphysical_used: data.physical_used,\n\t\t\t\t\tphysical_free: data.physical_free,\n\t\t\t\t\tvirtual: data.virtual,\n\t\t\t\t\tprivate: data.private,\n\t\t\t\t\tphysical: data.physical\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'memory',\n\t\t\t\t\t\tphysical_total: data.physical_total,\n\t\t\t\t\t\tphysical_used: data.physical_used,\n\t\t\t\t\t\tphysical_free: data.physical_free,\n\t\t\t\t\t\tvirtual: data.virtual,\n\t\t\t\t\t\tprivate: data.private,\n\t\t\t\t\t\tphysical: data.physical\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('https', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tMonitorHTTPSInbounds.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tmethod: data.method,\n\t\t\t\t\turl: data.url,\n\t\t\t\t\tduration: data.duration,\n\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\trequestHeader: data.requestHeader\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'https-inbound',\n\t\t\t\t\t\tmethod: data.method,\n\t\t\t\t\t\turl: data.url,\n\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\t\trequestHeader: data.requestHeader\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('https-outbound', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tMonitorHTTPSOutbounds.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\tmethod: data.method,\n\t\t\t\t\turl: data.url,\n\t\t\t\t\tduration: data.duration,\n\t\t\t\t\tstatus: data.status,\n\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\trequestHeaders: data.requestHeaders\n\t\t\t\t});\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (!data.url.startsWith('https://backend.resolveio.com/api/monitor/')) {\n\t\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\t\ttype: 'https-outbound',\n\t\t\t\t\t\t\tmethod: data.method,\n\t\t\t\t\t\t\turl: data.url,\n\t\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\t\tstatus: data.status,\n\t\t\t\t\t\t\tcontentType: data.contentType,\n\t\t\t\t\t\t\trequestHeaders: data.requestHeaders\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('mongo', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tif (!data.collection.startsWith('monitor-')) {\n\t\t\t\t\tMonitorMongos.create({\n\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\tmethod: data.method,\n\t\t\t\t\t\tdoc_collection: data.collection,\n\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\tquery: data.query\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (this._instanceHostname) {\n\t\t\t\t\tthis._monitorData.push({\n\t\t\t\t\t\tinstance: this._instanceHostname,\n\t\t\t\t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t\t\t\t\tdate: new Date(data.time),\n\t\t\t\t\t\ttype: 'mongo',\n\t\t\t\t\t\tmethod: data.method,\n\t\t\t\t\t\tdoc_collection: data.collection,\n\t\t\t\t\t\tduration: data.duration,\n\t\t\t\t\t\tquery: data.query\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis._monitorAgent.on('eventloop', async (data) => {\n\t\t\tif (this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\t\t\t\tconsole.log(JSON.stringify(data, null, 2));\n\t\t\t}\n\t\t});\n\n\t\t// this._monitorAgent.on('socket', async (data) => {\n\t\t// \tif (this._serverConfig['ROOT_URL'] === 'https://resolveio.com' || this._serverConfig['ROOT_URL'] === 'http://localhost:4200') {\n\n\t\t// \t}\n\t\t// \telse {\n\t\t// \t\tconst response = await post('/api/monitor/socket', {\n\t\t// \t\t\tclient: this._serverConfig['CLIENT_NAME'],\n\t\t// \t\t\tdate: new Date(data.time),\n\t\t\t\t\t\n\t\t// \t\t});\n\t\t// \t}\n\t\t// });\n\t}\n\n\tsetupEventLoop() {\n\t\tsetTimeout(async () => {\n\t\t\tif (this._monitorData.length) {\n\t\t\t\tconst post = bent('https://backend.resolveio.com', 'POST', 'json', 200);\n\n\t\t\t\tlet monitorData = deepCopy(this._monitorData);\n\t\t\t\tthis._monitorData = [];\n\n\t\t\t\tlet size = JSON.stringify(monitorData).replace(/[\\[\\]\\,\\\"]/g,'').length * 8;\n\n\t\t\t\tif (size < 45000000) { // 50 MB size limit\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst response = await post('/api/monitor', monitorData);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\tif (e.statusCode !== 500 && e.statusCode !== 501 && e.statusCode !== 502 && e.statusCode !== 503 && e.statusCode !== 504) {\n\t\t\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'RESOLVEIO MONITOR HTTP - Error Detected', JSON.stringify(e, null, 2));\n\n\t\t\t\t\t\t\tconsole.log(e);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet tmpData = [];\n\t\t\t\t\tfor (let i = 0; i < monitorData.length; i++) {\n\t\t\t\t\t\ttmpData.push(monitorData[i]);\n\t\t\t\t\t\tsize = JSON.stringify(tmpData).replace(/[\\[\\]\\,\\\"]/g,'').length * 8;\n\n\t\t\t\t\t\tif (size > 45000000) {\n\t\t\t\t\t\t\ttmpData.pop();\n\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst response = await post('/api/monitor', tmpData);\n\n\t\t\t\t\t\t\t\ttmpData = [monitorData[i]];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\t\tif (e.statusCode !== 500 && e.statusCode !== 501 && e.statusCode !== 502 && e.statusCode !== 503 && e.statusCode !== 504) {\n\t\t\t\t\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'RESOLVEIO MONITOR HTTP - Error Detected', JSON.stringify(e, null, 2));\n\t\t\n\t\t\t\t\t\t\t\t\tconsole.log(e);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (tmpData.length) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst response = await post('/api/monitor', tmpData);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\tif (e.statusCode !== 500 && e.statusCode !== 501 && e.statusCode !== 502 && e.statusCode !== 503 && e.statusCode !== 504) {\n\t\t\t\t\t\t\t\tResolveIOServer.getMainServer().getMethodManager().sendEmail('dev@resolveio.com', 'RESOLVEIO MONITOR HTTP - Error Detected', JSON.stringify(e, null, 2));\n\t\n\t\t\t\t\t\t\t\tconsole.log(e);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.setupEventLoop();\n\t\t}, 60000);\n\t}\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "9.7.16",
3
+ "version": "9.7.18",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -32,7 +32,7 @@
32
32
  "jwt-decode": "3.1.2",
33
33
  "moment": "2.29.1",
34
34
  "moment-timezone": "0.5.31",
35
- "mongodb": "3.7.1",
35
+ "mongodb": "4.1.3",
36
36
  "node-cache": "5.1.2",
37
37
  "node-google-timezone": "0.1.1",
38
38
  "nodemailer": "6.4.14",
@@ -90,7 +90,7 @@
90
90
  "jwt-decode": "3.1.2",
91
91
  "moment": "2.29.1",
92
92
  "moment-timezone": "0.5.31",
93
- "mongodb": "3.7.1",
93
+ "mongodb": "4.1.3",
94
94
  "node-cache": "5.1.2",
95
95
  "node-google-timezone": "0.1.1",
96
96
  "nodemailer": "6.4.14",
package/server-app.js CHANGED
@@ -83,7 +83,7 @@ var ResolveIOMainServer = /** @class */ (function () {
83
83
  this.standardProgram = standardProgram;
84
84
  this._serverStartTime = new Date();
85
85
  this._lastErrorMsg = null;
86
- if (serverConfig['ROOT_URL'] !== 'http://localhost:4200') {
86
+ if (monitorAgent) {
87
87
  this._monitorManager = new monitor_manager_1.MonitorManager(mainServer, monitorAgent, serverConfig);
88
88
  }
89
89
  process.on('unhandledRejection', function (error, rej) { return __awaiter(_this, void 0, void 0, function () {
package/server-app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/server-app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA4C;AAC5C,iCAAmC;AACnC,wCAA0C;AAC1C,kDAAoD;AACpD,8BAAgC;AAChC,kCAAoC;AACpC,6BAAoC;AACpC,kDAAoD;AACpD,+BAAiC;AAEjC,wCAAqE;AAErE,0DAA6D;AAC7D,wDAAsD;AACtD,4DAA0D;AAC1D,wEAAsE;AACtE,8DAA4D;AAI5D,uFAA2E;AAC3E,+DAAoD;AACpD,6FAAiF;AACjF,iEAAsD;AAEtD,oCAA8C;AAC9C,oCAA8C;AAC9C,wCAAkD;AAClD,iCAA0C;AAE1C;IAuBC,6BAAY,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe;QAArG,iBAiKC;QAjLO,cAAS,GAAG,EAAE,CAAC;QACf,qBAAgB,GAAG,KAAK,CAAC;QAC1B,YAAO,GAAG,KAAK,CAAC;QACf,oBAAe,GAAG,KAAK,CAAC;QAExB,WAA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C,EAAE,CAAC,CAAC;IAC9C,CAAC;IAEM,oCAAM,GAAb;QACC,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACF,0BAAC;AAAD,CAlrBA,AAkrBC,IAAA","file":"server-app.js","sourcesContent":["import { createServer, Server } from 'http';\nimport * as express from 'express';\nimport * as bodyParser from 'body-parser';\nimport * as xmlParser from 'express-xml-bodyparser';\nimport * as WebSocket from 'ws';\nimport * as jwt from 'jsonwebtoken';\nimport { v4 as uuidv4 } from 'uuid';\nimport * as SegfaultHandler from 'segfault-handler';\nimport * as moment from 'moment';\n\nimport { dateReviver, getBinarySize, deepCopy } from './util/common';\n\nimport { objectIdHexString } from './managers/mongo.manager';\nimport { CronManager } from './managers/cron.manager';\nimport { MethodManager } from './managers/method.manager';\nimport { SubscriptionManager } from './managers/subscription.manager';\nimport { MonitorManager } from './managers/monitor.manager';\n\nimport { ServerResponseModel } from './models/server-response.model';\n\nimport { MethodResponses } from './collections/method-response.collection';\nimport { Logs } from './collections/log.collection';\nimport { LogMethodLatencies } from './collections/log-method-latency.collection';\nimport { Users } from './collections/user.collection';\n\nimport { setupHomeRoutes } from './http/home';\nimport { setupAuthRoutes } from './http/auth';\nimport { setupHealthRoutes } from './http/health';\nimport { ResolveIOServer } from './index';\n\nexport default class ResolveIOMainServer {\n\tprivate _app: express.Application;\n\tprivate _server: Server;\n\tprivate _port: string | number;\n\tprivate _wss: WebSocket.Server;\n\tprivate _serverConfig;\n\tprivate _clientDir;\n\tprivate _msgQueue = [];\n\tprivate _msgQueueRunning = false;\n\tpublic sesMail = false;\n\tprivate standardProgram = false;\n\n\tprivate LOGGER = 'ERROR'; //ERROR / DEBUG\n\n\tprivate _monitorManager: MonitorManager;\n\tprivate _subscriptionManager: SubscriptionManager;\n\tprivate _methodManager: MethodManager;\n\tprivate _cronManager: CronManager;\n\tprivate _clientRoutes: string[] = [];\n\n\tprivate _serverStartTime: Date;\n\tprivate _lastErrorMsg: Date = null;\n\n\tconstructor(mainServer, monitorAgent, serverConfig, clientRoutes, clientDir, sesMail, standardProgram) {\n\t\tthis._serverConfig = serverConfig;\n\t\tthis._clientRoutes = clientRoutes;\n\t\tthis._clientDir = clientDir;\n\t\tthis.sesMail = sesMail;\n\t\tthis.standardProgram = standardProgram;\n\n\t\tthis._serverStartTime = new Date();\n\t\tthis._lastErrorMsg = null;\n\t\t\n\t\tif (serverConfig['ROOT_URL'] !== 'http://localhost:4200') {\n\t\t\tthis._monitorManager = new MonitorManager(mainServer, monitorAgent, serverConfig);\n\t\t}\n\n\t\tprocess.on('unhandledRejection', async (error, rej) => {\n\t\t\t// console.error(new Date(), 'Unhandled Rejection at Promise', [error, rej]);\n\n\t\t\tlet diffTimeSec = moment().diff(this._serverStartTime, 'seconds');\n\n\t\t\tif (error && error['name'] === 'MongoError' && error['message'] === 'not master') {\n\t\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t\t}, 60000);\n\n\t\t\t\t\tawait this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - Quitting NodeJS - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([error['name'], error['message'], error['stack']], null, 2));\n\t\t\t\t}\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\telse if (error && error['name'] === 'MongoError' && error['message'] === 'not master and slaveOk=false') {\n\t\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t\t}, 60000);\n\n\t\t\t\t\tawait this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - Quitting NodeJS - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([error['name'], error['message'], error['stack']], null, 2));\n\t\t\t\t}\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\telse if (error) {\n\t\t\t\tif (error['name'] !== 'StatusError' && error['message'] !== '') {\n\t\t\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t\t\t}, 60000);\n\n\t\t\t\t\t\tthis._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([error['name'], error['message'], error['stack']], null, 2));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tprocess.on('uncaughtException', async error => {\n\t\t\tconsole.error(error, 'Uncaught Exception thrown');\n\n\t\t\tlet diffTimeSec = moment().diff(this._serverStartTime, 'seconds');\n\n\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t}, 60000);\n\t\t\t\t\n\t\t\t\tawait this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Exception - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([error['name'], error['message'], error['stack']], null, 2));\n\t\t\t}\n\n\t\t\tprocess.exit(1);\n\t\t});\n\n\t\tSegfaultHandler.registerHandler('crash.log', async (signal, address, stack) => {\n\t\t\t// Do what you want with the signal, address, or stack (array)\n\t\t\t// This callback will execute before the signal is forwarded on.\n\n\t\t\tconsole.log('Segment Fault Detected');\n\t\t\tconsole.log('Signal', JSON.stringify(signal, null, 2));\n\t\t\tconsole.log('Address', JSON.stringify(address, null, 2));\n\t\t\tconsole.log('Stack', JSON.stringify(stack, null, 2));\n\n\t\t\tlet diffTimeSec = moment().diff(this._serverStartTime, 'seconds');\n\n\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\tawait this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Segfault - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([signal, address, stack], null, 2));\n\t\t\t}\n\n\t\t\tprocess.exit(1);\n\t\t});\n\n\t\t//SegfaultHandler.causeSegfault(); // simulates a buggy native module that dereferences NULL\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Starting ResolveIO Server');\n\t\t}\n\n\t\t// Start express app\n\t\tthis._app = express();\n\n\t\t// Use body parser for http call (login)\n\t\tthis._app.use(bodyParser.json({limit: '50mb', reviver: dateReviver}));\n\t\tthis._app.use(bodyParser.urlencoded({limit: '50mb', extended: true, parameterLimit: 1000000 }));\n\t\tthis._app.use(xmlParser());\n\t\t\n\t\t// Set port\n\t\tthis._port = process.env.PORT || serverConfig['PORT'];\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup ports');\n\t\t}\n\n\t\t// Create http server and websock server\n\t\tthis.createServer();\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Create server');\n\t\t}\n\t\t\n\t\t// Set CORS\n\t\tthis._app.use(function (req, res, next) {\n\n\t\t\t// Website you wish to allow to connect\n\t\t\t// res.setHeader('Access-Control-Allow-Origin', serverConfig['ROOT_URL']);\n\t\t\tres.setHeader('Access-Control-Allow-Origin', '*');\n\t\t\n\t\t\t// Request methods you wish to allow\n\t\t\t// res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');\n\t\t\tres.setHeader('Access-Control-Allow-Methods', 'GET, POST');\n\t\t\n\t\t\t// Request headers you wish to allow\n\t\t\tres.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');\n\t\t\n\t\t\t// Set to true if you need the website to include cookies in the requests sent\n\t\t\t// to the API (e.g. in case you use sessions)\n\t\t\tres.setHeader('Access-Control-Allow-Credentials', 'false');\n\t\t\n\t\t\t// Pass to next layer of middleware\n\t\t\tnext();\n\t\t});\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup cors');\n\t\t}\n\n\t\t// Set up http login route\n\t\tsetupAuthRoutes(this, this._app, serverConfig);\n\t\tsetupHealthRoutes(this._app, serverConfig);\n\n\t\tif (serverConfig['CLIENT_NAME'] === 'ResolveIO' || this.standardProgram) {\n\t\t\tsetupHomeRoutes(this, this._app, serverConfig);\n\t\t}\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup express routes');\n\t\t}\n\t}\n\n\tpublic getWS(id_ws: string) {\n\t\treturn Array.from(this._wss.clients).filter(a => a['id_socket'] === id_ws)[0];\n\t}\n\n\tpublic getWSList() {\n\t\tlet res = [];\n\n\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\tres.push(ws['id_socket']);\n\t\t});\n\n\t\treturn res;\n\t}\n\n\tpublic getWSUserList() {\n\t\tlet res = [];\n\n\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\tres.push(ws['id_user']);\n\t\t});\n\n\t\treturn res;\n\t}\n\n\tpublic getHTTPServer() {\n\t\treturn this._server;\n\t}\n\n\tpublic getCronManager() {\n\t\treturn this._cronManager;\n\t}\n\n\tpublic getMethodManager() {\n\t\treturn this._methodManager;\n\t}\n\n\tpublic getSubscriptionManager() {\n\t\treturn this._subscriptionManager;\n\t}\n\n\tpublic getMonitorManager() {\n\t\treturn this._monitorManager;\n\t}\n\n\tprivate createServer(): void {\n\t\t// Start express server\n\t\tthis._server = createServer(this._app);\n\t\tthis._server.keepAliveTimeout = 65000;\n\t\tthis._server.headersTimeout = 66000; // This should be bigger than `keepAliveTimeout + your server's expected response time`\n\n\t\t// Start websocket server\n\t\t// Verify client with token before opening socket\n\t\tthis._wss = new WebSocket.Server({ \n\t\t\tserver: this._server,\n\t\t\tverifyClient: async (info, cb) => {\n\t\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\t\tconsole.log('Verify Client', info, cb);\n\t\t\t\t}\n\n\t\t\t\tlet infoData = (<string>info.req.headers['sec-websocket-protocol']).split(/,/);\n\n\t\t\t\tif (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']) {\n\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (infoData[1]) { //app version\n\t\t\t\t\t\tlet token = infoData[0];\n\t\t\t\t\t\tif (!token) {\n\t\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tjwt.verify(token, this._serverConfig['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tinfo.req['id_user'] = decoded['id_user'];\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tlet user = await Users.findById(decoded['id_user']);\n\t\t\t\t\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['user'] = user.fullname;\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['user_readonly'] = user.readonly || false;\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['doc_user'] = user;\n\t\t\t\t\t\t\t\t\t\t\tcb(true);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\tcb(false);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\t\t\t\t\tcb(false);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tcb(false, 401, 'Invalid Version');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// Start MongoDB Connection\n\t\tthis.setUpMongo();\n\t}\n\n\tprivate setUpMongo() {\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Start Managers');\n\t\t}\n\n\t\t// Start Managers\n\t\tthis._subscriptionManager = new SubscriptionManager(this, this._wss, this._serverConfig);\n\t\tthis._methodManager = new MethodManager(this, this._serverConfig, this._clientDir);\n\t\tthis._cronManager = new CronManager(this);\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('End Managers');\n\t\t}\n\n\t\tthis.listen();\n\t}\n\n\t// Listen to port for websocket\n\tprivate listen(): void {\n\t\tthis._server.listen(this._port, () => {\n\t\t\tconsole.log('Running server on port %s', this._port);\n\t\t});\n\n\t\t// On websocket connection (already verified)\n\t\tthis._wss.on('connection', async (ws, req) => {\n\n\t\t\t// Get user from token\n\t\t\tws['id_user'] = req['id_user'];\n\t\t\tws['user'] = req['user'];\n\t\t\tws['user_readonly'] = req['user_readonly'];\n\t\t\tws['doc_user'] = req['doc_user'];\n\t\t\t\n\t\t\tlet idSocket = '';\n\n\t\t\twhile (!idSocket || Array.from(this._wss.clients).some(a => a['id_socket'] === idSocket)) {\n\t\t\t\tidSocket = uuidv4();\n\t\t\t}\n\n\t\t\tws['id_socket'] = idSocket;\n\t\t\tws['retryCnt'] = 0;\n\n\t\t\tawait this._subscriptionManager.createLoggedInUser(idSocket);\n\n\t\t\tsetTimeout(() => {\n\t\t\t\tws['pingTime'] = new Date();\n\t\t\t\tws.ping(() => {});\n\t\t\t}, 5000);\n\n\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\tconsole.log('Connection from: ' + req['user']);\n\t\t\t}\n\t\t\t\n\t\t\t// Use for keeping connection alive (ping/pong)\n\t\t\tws['isAlive'] = true;\n\t\t\tws.on('pong', () => {\n\t\t\t\tws['isAlive'] = true;\n\t\t\t\tws['pongTime'] = new Date();\n\t\t\t\tws['latency'] = moment.duration(moment(ws['pongTime']).diff(ws['pingTime'])).asMilliseconds();\n\t\t\t\tthis._subscriptionManager.loggedInLatency(ws);\n\t\t\t});\n\n\t\t\tws['versionTimer'] = setTimeout(() => {\n\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t}, 20000);\n\n\t\t\t// On data received (message)\n\t\t\tws.on('message', async (message: string) => {\n\t\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\t\tconsole.log('Message from: ' + ws['user'], message);\n\t\t\t\t}\n\n\t\t\t\tlet parseErrorFound = false;\n\n\t\t\t\tlet socketData = [];\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tsocketData = JSON.parse(message, dateReviver);\n\t\t\t\t}\n\t\t\t\tcatch(e) {\n\t\t\t\t\tconsole.log('Error - JSON.parse', message);\n\t\t\t\t\t\n\t\t\t\t\tthis._methodManager.sendEmail('dev@resolveio.com', 'SERVER - JSON Parse Error - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([message, e]));\n\n\t\t\t\t\tparseErrorFound = true;\n\t\t\t\t}\n\n\t\t\t\tif (!parseErrorFound) {\n\t\t\t\t\tif (socketData[0] === 'ping') {\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tws.send('pong', (error) => {\n\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet messageRoute = socketData[0];\n\n\t\t\t\t\tif (this._clientRoutes.some(a => messageRoute.includes(a)) && !ws['doc_user'].roles.groups.some(a => a.views.some(b => messageRoute.includes(b))) && !ws['doc_user'].roles.super_admin) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet messageDate = socketData[1];\n\t\t\t\t\tlet messageId = socketData[2]\n\t\t\t\t\tlet type = socketData[3]\n\n\t\t\t\t\tif (type === 'subscription') {\n\t\t\t\t\t\tlet subType = socketData[4];\n\t\t\t\t\t\tlet pub = socketData[5];\n\t\t\n\t\t\t\t\t\t// Subscribe\n\t\t\t\t\t\tif (subType === 'sub') {\n\t\t\t\t\t\t\tthis._subscriptionManager.subscribe(messageDate, ws, messageId, pub, ...socketData.slice(6));\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Unsubscribe\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._subscriptionManager.unsubscribe(messageDate, ws, messageId, pub, ...socketData.slice(6));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse if (type === 'offline') {\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'ACK'\n\t\t\t\t\t\t};\n\t\t\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tws.send(JSON.stringify(serverRes), (error) => {\n\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet offlineUpdates = socketData[4];\n\t\t\t\t\t\tfor (let i = 0; i < offlineUpdates.length; i++) {\n\t\t\t\t\t\t\tlet update = offlineUpdates[i];\n\n\t\t\t\t\t\t\tlet serverResMethod: ServerResponseModel = {\n\t\t\t\t\t\t\t\tmessageId: update.data[2],\n\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\tdata: 'ACK'\n\t\t\t\t\t\t\t};\n\t\t\t\n\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\tws.send(JSON.stringify(serverResMethod), (error) => {\n\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (let i = 0; i < offlineUpdates.length; i++) {\n\t\t\t\t\t\t\tlet update = offlineUpdates[i];\n\t\t\t\t\t\t\tlet data = update.data;\n\n\t\t\t\t\t\t\tif (update.oldData) {\n\t\t\t\t\t\t\t\tdata.push(update.oldData);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tlet updateRoute = data.shift();\n\t\t\t\t\t\t\tlet updateDate = data.shift();\n\t\t\t\t\t\t\tlet updateMessageId = data.shift();\n\t\t\t\t\t\t\tlet updateType = data.shift();\n\t\t\t\t\t\t\tlet method = data.shift();\n\t\t\t\t\t\t\tlet methodLatencyId = objectIdHexString();\n\n\t\t\t\t\t\t\tLogMethodLatencies.create({\n\t\t\t\t\t\t\t\t_id: methodLatencyId,\n\t\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\t\tdate_start: new Date(),\n\t\t\t\t\t\t\t\tdate_end: null,\n\t\t\t\t\t\t\t\tlatency_ms: 0,\n\t\t\t\t\t\t\t\tmethod: method\n\t\t\t\t\t\t\t});\n\t\t\t\n\t\t\t\t\t\t\tif (method !== 'reportBuilderGetResults' && method !== 'reportBuilderGetDistinctValue' && method !== 'reportBuilderBuildTree' && method !== 'generatePDF' && method !== 'getWOOfflineData' && method !== 'countQuery' && method !== 'countWithQuery' && method !== 'countCollectionWithQuery' && method !== 'find' && method !== 'findOne' && method !== 'findWithOptions' && method !== 'setWSAppVersion' && method !== 'getDrivers') {\n\t\t\t\t\t\t\t\tLogs.insertOne({\n\t\t\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\t\t\tpayload: getBinarySize(JSON.stringify(data)) < 200000 ? JSON.stringify(data, null, 2) : 'Too Big',\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tid_user: ws['id_user'] || '',\n\t\t\t\t\t\t\t\t\tuser: ws['user'] || '',\n\t\t\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\t\t\troute: messageRoute\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\t\t\t\t\t\tawait this._methodManager.callMethodInternal.call(Object.assign({}, this._methodManager, {id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket']}), method, ...data);\n\n\t\t\t\t\t\t\t\tif (method === 'updateDocumentOffline' || method === 'updateDocumentPropsOffline') {\n\t\t\t\t\t\t\t\t\tResolveIOServer.getMongoManager().invalidateQueryCache(data[0]);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tconsole.log('Offline - Could not find method: ' + method);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse if (type === 'method' && socketData[4] === 'setWSAppVersion') {\n\t\t\t\t\t\tclearTimeout(ws['versionTimer']);\n\n\t\t\t\t\t\tlet method = socketData[4];\n\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'ACK'\n\t\t\t\t\t\t};\n\t\t\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tws.send(JSON.stringify(serverRes), (error) => {\n\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet methodLatencyId = objectIdHexString();\n\n\t\t\t\t\t\tLogMethodLatencies.create({\n\t\t\t\t\t\t\t_id: methodLatencyId,\n\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\tdate_start: new Date(),\n\t\t\t\t\t\t\tdate_end: null,\n\t\t\t\t\t\t\tlatency_ms: 0,\n\t\t\t\t\t\t\tmethod: method\n\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\t\t\t\t\tthis._methodManager.callMethod(methodLatencyId, <any>ws, messageDate, messageId, method, ...socketData.slice(5));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log('Could not find method: ' + method);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis._msgQueue.splice(0, 0, {\n\t\t\t\t\t\t\tws: ws,\n\t\t\t\t\t\t\tdata: socketData\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tws.on('close', () => {\n\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t});\n\n\t\t\tws.on('error', error => {\n\t\t\t\tconsole.log(new Date(), ws['user'], ws['id_socket'], error);\n\t\t\t\t\n\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t});\n\t\t});\n\n\t\t// Keep alive timer to ping/pong\n\t\tsetInterval(() => {\n\t\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\t\tif (ws['isAlive'] === false) {\n\t\t\t\t\tws['retryCnt']++;\n\n\t\t\t\t\tif (ws['retryCnt'] >= 60) {\n\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tws['pingTime'] = new Date();\n\t\t\t\t\t\tws.ping(() => {});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tws['retryCnt'] = 0;\n\t\t\t\t\tws['isAlive'] = false;\n\t\t\t\t\tws['pingTime'] = new Date();\n\t\t\t\t\tws.ping(() => {});\n\t\t\t\t}\n\t\t\t});\n\t\t}, 15000);\n\n\t\tsetInterval(async () => {\n\t\t\tif (!this._msgQueueRunning) {\t\t\t\t\n\t\t\t\tif (this._msgQueue.length) {\n\t\t\t\t\tthis._msgQueueRunning = true;\n\t\t\t\t\tfor (let i = this._msgQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tlet msg = this._msgQueue.pop();\n\t\t\t\t\t\tlet data = msg.data;\n\t\t\t\t\t\tlet ws = msg.ws;\n\t\t\t\n\t\t\t\t\t\tlet messageRoute: string = data.shift();\n\t\t\t\t\t\tlet messageDate: Date = data.shift();\n\t\t\t\t\t\tlet messageId: number = data.shift();\n\t\t\t\t\t\tlet type: string = data.shift();\n\t\t\t\n\t\t\t\t\t\t// Method call\n\t\t\t\t\t\tif (type === 'method') {\n\t\t\t\t\t\t\tlet method = data.shift();\n\n\t\t\t\t\t\t\tif (ws['user_readonly']) {\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tlet methodLatencyId = objectIdHexString();\n\n\t\t\t\t\t\t\tLogMethodLatencies.create({\n\t\t\t\t\t\t\t\t_id: methodLatencyId,\n\t\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\t\tdate_start: new Date(),\n\t\t\t\t\t\t\t\tdate_end: null,\n\t\t\t\t\t\t\t\tlatency_ms: 0,\n\t\t\t\t\t\t\t\tmethod: method\n\t\t\t\t\t\t\t});\n\t\t\t\n\t\t\t\t\t\t\tif (method !== 'reportBuilderGetResults' && method !== 'reportBuilderGetDistinctValue' && method !== 'reportBuilderBuildTree' && method !== 'generatePDF' && method !== 'getWOOfflineData' && method !== 'countQuery' && method !== 'countWithQuery' && method !== 'countCollectionWithQuery' && method !== 'find' && method !== 'findOne' && method !== 'findWithOptions' && method !== 'getDrivers') {\n\t\t\t\t\t\t\t\tLogs.insertOne({\n\t\t\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\t\t\tpayload: getBinarySize(JSON.stringify(data)) < 200000 ? JSON.stringify(data, null, 2) : 'Too Big',\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tid_user: ws['id_user'] || '',\n\t\t\t\t\t\t\t\t\tuser: ws['user'] || '',\n\t\t\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\t\t\troute: messageRoute\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\n\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\tdata: 'ACK'\n\t\t\t\t\t\t\t};\n\t\t\t\n\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\tws.send(JSON.stringify(serverRes), (error) => {\n\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\n\t\t\t\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\t\t\t\t\t\tthis._methodManager.callMethod(methodLatencyId, ws, messageDate, messageId, method, ...data);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tconsole.log('Could not find method: ' + method);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (type === 'methodResponse') {\n\t\t\t\t\t\t\tlet method = data.shift();\n\t\t\t\n\t\t\t\t\t\t\tMethodResponses.findOne({$and: [\n\t\t\t\t\t\t\t\t{id_user: ws['id_user']}, \n\t\t\t\t\t\t\t\t{message_id: messageId},\n\t\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t\t{date: messageDate}\n\t\t\t\t\t\t\t]}).then(res => {\n\t\t\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\t\t\tws.send(JSON.stringify(res.response), (error) => {\n\t\t\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}, err => {});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tthis._msgQueueRunning = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}, 1);\n\t}\n\n\tpublic unsubscribeWS(ws: WebSocket) {\n\t\tthis._subscriptionManager.unsubscribeAll(ws);\n\t}\n\n\tpublic getApp() {\n\t\treturn this._app;\n\t}\n}"]}
1
+ {"version":3,"sources":["../../src/server-app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC,EAAE,UAAC,KAAK;gDAC3C,IAAI,KAAK,EAAE;oDACV,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;oDACpC,KAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;iDACvB;4CACF,CAAC,CAAC,CAAC;yCACH;qCACD;gCACF,CAAC,EAAE,UAAA,GAAG,IAAK,CAAC,CAAC,CAAC;6BACd;;;wBAtFF,KAAS,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;oCAA1C,CAAC;yBAuFT;wBAED,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;qBAC9B;iBACD;;;aACD,EAAE,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,2CAAa,GAApB,UAAqB,EAAa;QACjC,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IAC9C,CAAC;IAEM,oCAAM,GAAb;QACC,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACF,0BAAC;AAAD,CAlrBA,AAkrBC,IAAA","file":"server-app.js","sourcesContent":["import { createServer, Server } from 'http';\nimport * as express from 'express';\nimport * as bodyParser from 'body-parser';\nimport * as xmlParser from 'express-xml-bodyparser';\nimport * as WebSocket from 'ws';\nimport * as jwt from 'jsonwebtoken';\nimport { v4 as uuidv4 } from 'uuid';\nimport * as SegfaultHandler from 'segfault-handler';\nimport * as moment from 'moment';\n\nimport { dateReviver, getBinarySize, deepCopy } from './util/common';\n\nimport { objectIdHexString } from './managers/mongo.manager';\nimport { CronManager } from './managers/cron.manager';\nimport { MethodManager } from './managers/method.manager';\nimport { SubscriptionManager } from './managers/subscription.manager';\nimport { MonitorManager } from './managers/monitor.manager';\n\nimport { ServerResponseModel } from './models/server-response.model';\n\nimport { MethodResponses } from './collections/method-response.collection';\nimport { Logs } from './collections/log.collection';\nimport { LogMethodLatencies } from './collections/log-method-latency.collection';\nimport { Users } from './collections/user.collection';\n\nimport { setupHomeRoutes } from './http/home';\nimport { setupAuthRoutes } from './http/auth';\nimport { setupHealthRoutes } from './http/health';\nimport { ResolveIOServer } from './index';\n\nexport default class ResolveIOMainServer {\n\tprivate _app: express.Application;\n\tprivate _server: Server;\n\tprivate _port: string | number;\n\tprivate _wss: WebSocket.Server;\n\tprivate _serverConfig;\n\tprivate _clientDir;\n\tprivate _msgQueue = [];\n\tprivate _msgQueueRunning = false;\n\tpublic sesMail = false;\n\tprivate standardProgram = false;\n\n\tprivate LOGGER = 'ERROR'; //ERROR / DEBUG\n\n\tprivate _monitorManager: MonitorManager;\n\tprivate _subscriptionManager: SubscriptionManager;\n\tprivate _methodManager: MethodManager;\n\tprivate _cronManager: CronManager;\n\tprivate _clientRoutes: string[] = [];\n\n\tprivate _serverStartTime: Date;\n\tprivate _lastErrorMsg: Date = null;\n\n\tconstructor(mainServer, monitorAgent, serverConfig, clientRoutes, clientDir, sesMail, standardProgram) {\n\t\tthis._serverConfig = serverConfig;\n\t\tthis._clientRoutes = clientRoutes;\n\t\tthis._clientDir = clientDir;\n\t\tthis.sesMail = sesMail;\n\t\tthis.standardProgram = standardProgram;\n\n\t\tthis._serverStartTime = new Date();\n\t\tthis._lastErrorMsg = null;\n\t\t\n\t\tif (monitorAgent) {\n\t\t\tthis._monitorManager = new MonitorManager(mainServer, monitorAgent, serverConfig);\n\t\t}\n\n\t\tprocess.on('unhandledRejection', async (error, rej) => {\n\t\t\t// console.error(new Date(), 'Unhandled Rejection at Promise', [error, rej]);\n\n\t\t\tlet diffTimeSec = moment().diff(this._serverStartTime, 'seconds');\n\n\t\t\tif (error && error['name'] === 'MongoError' && error['message'] === 'not master') {\n\t\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t\t}, 60000);\n\n\t\t\t\t\tawait this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - Quitting NodeJS - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([error['name'], error['message'], error['stack']], null, 2));\n\t\t\t\t}\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\telse if (error && error['name'] === 'MongoError' && error['message'] === 'not master and slaveOk=false') {\n\t\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t\t}, 60000);\n\n\t\t\t\t\tawait this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - Quitting NodeJS - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([error['name'], error['message'], error['stack']], null, 2));\n\t\t\t\t}\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\telse if (error) {\n\t\t\t\tif (error['name'] !== 'StatusError' && error['message'] !== '') {\n\t\t\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t\t\t}, 60000);\n\n\t\t\t\t\t\tthis._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Rejection - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([error['name'], error['message'], error['stack']], null, 2));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tprocess.on('uncaughtException', async error => {\n\t\t\tconsole.error(error, 'Uncaught Exception thrown');\n\n\t\t\tlet diffTimeSec = moment().diff(this._serverStartTime, 'seconds');\n\n\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\tthis._lastErrorMsg = new Date();\n\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis._lastErrorMsg = null;\n\t\t\t\t}, 60000);\n\t\t\t\t\n\t\t\t\tawait this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Unhandled Exception - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([error['name'], error['message'], error['stack']], null, 2));\n\t\t\t}\n\n\t\t\tprocess.exit(1);\n\t\t});\n\n\t\tSegfaultHandler.registerHandler('crash.log', async (signal, address, stack) => {\n\t\t\t// Do what you want with the signal, address, or stack (array)\n\t\t\t// This callback will execute before the signal is forwarded on.\n\n\t\t\tconsole.log('Segment Fault Detected');\n\t\t\tconsole.log('Signal', JSON.stringify(signal, null, 2));\n\t\t\tconsole.log('Address', JSON.stringify(address, null, 2));\n\t\t\tconsole.log('Stack', JSON.stringify(stack, null, 2));\n\n\t\t\tlet diffTimeSec = moment().diff(this._serverStartTime, 'seconds');\n\n\t\t\tif (diffTimeSec > 60 && !this._lastErrorMsg) {\n\t\t\t\tawait this._methodManager.sendEmail('dev@resolveio.com', 'SERVER - Segfault - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([signal, address, stack], null, 2));\n\t\t\t}\n\n\t\t\tprocess.exit(1);\n\t\t});\n\n\t\t//SegfaultHandler.causeSegfault(); // simulates a buggy native module that dereferences NULL\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Starting ResolveIO Server');\n\t\t}\n\n\t\t// Start express app\n\t\tthis._app = express();\n\n\t\t// Use body parser for http call (login)\n\t\tthis._app.use(bodyParser.json({limit: '50mb', reviver: dateReviver}));\n\t\tthis._app.use(bodyParser.urlencoded({limit: '50mb', extended: true, parameterLimit: 1000000 }));\n\t\tthis._app.use(xmlParser());\n\t\t\n\t\t// Set port\n\t\tthis._port = process.env.PORT || serverConfig['PORT'];\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup ports');\n\t\t}\n\n\t\t// Create http server and websock server\n\t\tthis.createServer();\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Create server');\n\t\t}\n\t\t\n\t\t// Set CORS\n\t\tthis._app.use(function (req, res, next) {\n\n\t\t\t// Website you wish to allow to connect\n\t\t\t// res.setHeader('Access-Control-Allow-Origin', serverConfig['ROOT_URL']);\n\t\t\tres.setHeader('Access-Control-Allow-Origin', '*');\n\t\t\n\t\t\t// Request methods you wish to allow\n\t\t\t// res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');\n\t\t\tres.setHeader('Access-Control-Allow-Methods', 'GET, POST');\n\t\t\n\t\t\t// Request headers you wish to allow\n\t\t\tres.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');\n\t\t\n\t\t\t// Set to true if you need the website to include cookies in the requests sent\n\t\t\t// to the API (e.g. in case you use sessions)\n\t\t\tres.setHeader('Access-Control-Allow-Credentials', 'false');\n\t\t\n\t\t\t// Pass to next layer of middleware\n\t\t\tnext();\n\t\t});\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup cors');\n\t\t}\n\n\t\t// Set up http login route\n\t\tsetupAuthRoutes(this, this._app, serverConfig);\n\t\tsetupHealthRoutes(this._app, serverConfig);\n\n\t\tif (serverConfig['CLIENT_NAME'] === 'ResolveIO' || this.standardProgram) {\n\t\t\tsetupHomeRoutes(this, this._app, serverConfig);\n\t\t}\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Setup express routes');\n\t\t}\n\t}\n\n\tpublic getWS(id_ws: string) {\n\t\treturn Array.from(this._wss.clients).filter(a => a['id_socket'] === id_ws)[0];\n\t}\n\n\tpublic getWSList() {\n\t\tlet res = [];\n\n\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\tres.push(ws['id_socket']);\n\t\t});\n\n\t\treturn res;\n\t}\n\n\tpublic getWSUserList() {\n\t\tlet res = [];\n\n\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\tres.push(ws['id_user']);\n\t\t});\n\n\t\treturn res;\n\t}\n\n\tpublic getHTTPServer() {\n\t\treturn this._server;\n\t}\n\n\tpublic getCronManager() {\n\t\treturn this._cronManager;\n\t}\n\n\tpublic getMethodManager() {\n\t\treturn this._methodManager;\n\t}\n\n\tpublic getSubscriptionManager() {\n\t\treturn this._subscriptionManager;\n\t}\n\n\tpublic getMonitorManager() {\n\t\treturn this._monitorManager;\n\t}\n\n\tprivate createServer(): void {\n\t\t// Start express server\n\t\tthis._server = createServer(this._app);\n\t\tthis._server.keepAliveTimeout = 65000;\n\t\tthis._server.headersTimeout = 66000; // This should be bigger than `keepAliveTimeout + your server's expected response time`\n\n\t\t// Start websocket server\n\t\t// Verify client with token before opening socket\n\t\tthis._wss = new WebSocket.Server({ \n\t\t\tserver: this._server,\n\t\t\tverifyClient: async (info, cb) => {\n\t\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\t\tconsole.log('Verify Client', info, cb);\n\t\t\t\t}\n\n\t\t\t\tlet infoData = (<string>info.req.headers['sec-websocket-protocol']).split(/,/);\n\n\t\t\t\tif (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']) {\n\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tif (infoData[1]) { //app version\n\t\t\t\t\t\tlet token = infoData[0];\n\t\t\t\t\t\tif (!token) {\n\t\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tjwt.verify(token, this._serverConfig['JWT_SECRET'], async (err, decoded) => {\n\t\t\t\t\t\t\t\tif (err) {\n\t\t\t\t\t\t\t\t\tcb(false, 401, 'Unauthorized');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tinfo.req['id_user'] = decoded['id_user'];\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tlet user = await Users.findById(decoded['id_user']);\n\t\t\t\t\t\t\t\t\t\tif (user) {\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['user'] = user.fullname;\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['user_readonly'] = user.readonly || false;\n\t\t\t\t\t\t\t\t\t\t\tinfo.req['doc_user'] = user;\n\t\t\t\t\t\t\t\t\t\t\tcb(true);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\tcb(false);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcatch (err) {\n\t\t\t\t\t\t\t\t\t\tcb(false);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tcb(false, 401, 'Invalid Version');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// Start MongoDB Connection\n\t\tthis.setUpMongo();\n\t}\n\n\tprivate setUpMongo() {\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('Start Managers');\n\t\t}\n\n\t\t// Start Managers\n\t\tthis._subscriptionManager = new SubscriptionManager(this, this._wss, this._serverConfig);\n\t\tthis._methodManager = new MethodManager(this, this._serverConfig, this._clientDir);\n\t\tthis._cronManager = new CronManager(this);\n\n\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\tconsole.log('End Managers');\n\t\t}\n\n\t\tthis.listen();\n\t}\n\n\t// Listen to port for websocket\n\tprivate listen(): void {\n\t\tthis._server.listen(this._port, () => {\n\t\t\tconsole.log('Running server on port %s', this._port);\n\t\t});\n\n\t\t// On websocket connection (already verified)\n\t\tthis._wss.on('connection', async (ws, req) => {\n\n\t\t\t// Get user from token\n\t\t\tws['id_user'] = req['id_user'];\n\t\t\tws['user'] = req['user'];\n\t\t\tws['user_readonly'] = req['user_readonly'];\n\t\t\tws['doc_user'] = req['doc_user'];\n\t\t\t\n\t\t\tlet idSocket = '';\n\n\t\t\twhile (!idSocket || Array.from(this._wss.clients).some(a => a['id_socket'] === idSocket)) {\n\t\t\t\tidSocket = uuidv4();\n\t\t\t}\n\n\t\t\tws['id_socket'] = idSocket;\n\t\t\tws['retryCnt'] = 0;\n\n\t\t\tawait this._subscriptionManager.createLoggedInUser(idSocket);\n\n\t\t\tsetTimeout(() => {\n\t\t\t\tws['pingTime'] = new Date();\n\t\t\t\tws.ping(() => {});\n\t\t\t}, 5000);\n\n\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\tconsole.log('Connection from: ' + req['user']);\n\t\t\t}\n\t\t\t\n\t\t\t// Use for keeping connection alive (ping/pong)\n\t\t\tws['isAlive'] = true;\n\t\t\tws.on('pong', () => {\n\t\t\t\tws['isAlive'] = true;\n\t\t\t\tws['pongTime'] = new Date();\n\t\t\t\tws['latency'] = moment.duration(moment(ws['pongTime']).diff(ws['pingTime'])).asMilliseconds();\n\t\t\t\tthis._subscriptionManager.loggedInLatency(ws);\n\t\t\t});\n\n\t\t\tws['versionTimer'] = setTimeout(() => {\n\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t}, 20000);\n\n\t\t\t// On data received (message)\n\t\t\tws.on('message', async (message: string) => {\n\t\t\t\tif (this.LOGGER === 'DEBUG') {\n\t\t\t\t\tconsole.log('Message from: ' + ws['user'], message);\n\t\t\t\t}\n\n\t\t\t\tlet parseErrorFound = false;\n\n\t\t\t\tlet socketData = [];\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tsocketData = JSON.parse(message, dateReviver);\n\t\t\t\t}\n\t\t\t\tcatch(e) {\n\t\t\t\t\tconsole.log('Error - JSON.parse', message);\n\t\t\t\t\t\n\t\t\t\t\tthis._methodManager.sendEmail('dev@resolveio.com', 'SERVER - JSON Parse Error - ' + this._serverConfig['CLIENT_NAME'], JSON.stringify([message, e]));\n\n\t\t\t\t\tparseErrorFound = true;\n\t\t\t\t}\n\n\t\t\t\tif (!parseErrorFound) {\n\t\t\t\t\tif (socketData[0] === 'ping') {\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tws.send('pong', (error) => {\n\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet messageRoute = socketData[0];\n\n\t\t\t\t\tif (this._clientRoutes.some(a => messageRoute.includes(a)) && !ws['doc_user'].roles.groups.some(a => a.views.some(b => messageRoute.includes(b))) && !ws['doc_user'].roles.super_admin) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet messageDate = socketData[1];\n\t\t\t\t\tlet messageId = socketData[2]\n\t\t\t\t\tlet type = socketData[3]\n\n\t\t\t\t\tif (type === 'subscription') {\n\t\t\t\t\t\tlet subType = socketData[4];\n\t\t\t\t\t\tlet pub = socketData[5];\n\t\t\n\t\t\t\t\t\t// Subscribe\n\t\t\t\t\t\tif (subType === 'sub') {\n\t\t\t\t\t\t\tthis._subscriptionManager.subscribe(messageDate, ws, messageId, pub, ...socketData.slice(6));\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// Unsubscribe\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._subscriptionManager.unsubscribe(messageDate, ws, messageId, pub, ...socketData.slice(6));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse if (type === 'offline') {\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'ACK'\n\t\t\t\t\t\t};\n\t\t\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tws.send(JSON.stringify(serverRes), (error) => {\n\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet offlineUpdates = socketData[4];\n\t\t\t\t\t\tfor (let i = 0; i < offlineUpdates.length; i++) {\n\t\t\t\t\t\t\tlet update = offlineUpdates[i];\n\n\t\t\t\t\t\t\tlet serverResMethod: ServerResponseModel = {\n\t\t\t\t\t\t\t\tmessageId: update.data[2],\n\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\tdata: 'ACK'\n\t\t\t\t\t\t\t};\n\t\t\t\n\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\tws.send(JSON.stringify(serverResMethod), (error) => {\n\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (let i = 0; i < offlineUpdates.length; i++) {\n\t\t\t\t\t\t\tlet update = offlineUpdates[i];\n\t\t\t\t\t\t\tlet data = update.data;\n\n\t\t\t\t\t\t\tif (update.oldData) {\n\t\t\t\t\t\t\t\tdata.push(update.oldData);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tlet updateRoute = data.shift();\n\t\t\t\t\t\t\tlet updateDate = data.shift();\n\t\t\t\t\t\t\tlet updateMessageId = data.shift();\n\t\t\t\t\t\t\tlet updateType = data.shift();\n\t\t\t\t\t\t\tlet method = data.shift();\n\t\t\t\t\t\t\tlet methodLatencyId = objectIdHexString();\n\n\t\t\t\t\t\t\tLogMethodLatencies.create({\n\t\t\t\t\t\t\t\t_id: methodLatencyId,\n\t\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\t\tdate_start: new Date(),\n\t\t\t\t\t\t\t\tdate_end: null,\n\t\t\t\t\t\t\t\tlatency_ms: 0,\n\t\t\t\t\t\t\t\tmethod: method\n\t\t\t\t\t\t\t});\n\t\t\t\n\t\t\t\t\t\t\tif (method !== 'reportBuilderGetResults' && method !== 'reportBuilderGetDistinctValue' && method !== 'reportBuilderBuildTree' && method !== 'generatePDF' && method !== 'getWOOfflineData' && method !== 'countQuery' && method !== 'countWithQuery' && method !== 'countCollectionWithQuery' && method !== 'find' && method !== 'findOne' && method !== 'findWithOptions' && method !== 'setWSAppVersion' && method !== 'getDrivers') {\n\t\t\t\t\t\t\t\tLogs.insertOne({\n\t\t\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\t\t\tpayload: getBinarySize(JSON.stringify(data)) < 200000 ? JSON.stringify(data, null, 2) : 'Too Big',\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tid_user: ws['id_user'] || '',\n\t\t\t\t\t\t\t\t\tuser: ws['user'] || '',\n\t\t\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\t\t\troute: messageRoute\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\t\t\t\t\t\tawait this._methodManager.callMethodInternal.call(Object.assign({}, this._methodManager, {id_user: ws['id_user'], user: ws['user'], id_ws: ws['id_socket']}), method, ...data);\n\n\t\t\t\t\t\t\t\tif (method === 'updateDocumentOffline' || method === 'updateDocumentPropsOffline') {\n\t\t\t\t\t\t\t\t\tResolveIOServer.getMongoManager().invalidateQueryCache(data[0]);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tconsole.log('Offline - Could not find method: ' + method);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse if (type === 'method' && socketData[4] === 'setWSAppVersion') {\n\t\t\t\t\t\tclearTimeout(ws['versionTimer']);\n\n\t\t\t\t\t\tlet method = socketData[4];\n\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: 'ACK'\n\t\t\t\t\t\t};\n\t\t\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tws.send(JSON.stringify(serverRes), (error) => {\n\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet methodLatencyId = objectIdHexString();\n\n\t\t\t\t\t\tLogMethodLatencies.create({\n\t\t\t\t\t\t\t_id: methodLatencyId,\n\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\tdate_start: new Date(),\n\t\t\t\t\t\t\tdate_end: null,\n\t\t\t\t\t\t\tlatency_ms: 0,\n\t\t\t\t\t\t\tmethod: method\n\t\t\t\t\t\t});\n\t\t\n\t\t\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\t\t\t\t\tthis._methodManager.callMethod(methodLatencyId, <any>ws, messageDate, messageId, method, ...socketData.slice(5));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tconsole.log('Could not find method: ' + method);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis._msgQueue.splice(0, 0, {\n\t\t\t\t\t\t\tws: ws,\n\t\t\t\t\t\t\tdata: socketData\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tws.on('close', () => {\n\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t});\n\n\t\t\tws.on('error', error => {\n\t\t\t\tconsole.log(new Date(), ws['user'], ws['id_socket'], error);\n\t\t\t\t\n\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t});\n\t\t});\n\n\t\t// Keep alive timer to ping/pong\n\t\tsetInterval(() => {\n\t\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\t\tif (ws['isAlive'] === false) {\n\t\t\t\t\tws['retryCnt']++;\n\n\t\t\t\t\tif (ws['retryCnt'] >= 60) {\n\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tws['pingTime'] = new Date();\n\t\t\t\t\t\tws.ping(() => {});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tws['retryCnt'] = 0;\n\t\t\t\t\tws['isAlive'] = false;\n\t\t\t\t\tws['pingTime'] = new Date();\n\t\t\t\t\tws.ping(() => {});\n\t\t\t\t}\n\t\t\t});\n\t\t}, 15000);\n\n\t\tsetInterval(async () => {\n\t\t\tif (!this._msgQueueRunning) {\t\t\t\t\n\t\t\t\tif (this._msgQueue.length) {\n\t\t\t\t\tthis._msgQueueRunning = true;\n\t\t\t\t\tfor (let i = this._msgQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tlet msg = this._msgQueue.pop();\n\t\t\t\t\t\tlet data = msg.data;\n\t\t\t\t\t\tlet ws = msg.ws;\n\t\t\t\n\t\t\t\t\t\tlet messageRoute: string = data.shift();\n\t\t\t\t\t\tlet messageDate: Date = data.shift();\n\t\t\t\t\t\tlet messageId: number = data.shift();\n\t\t\t\t\t\tlet type: string = data.shift();\n\t\t\t\n\t\t\t\t\t\t// Method call\n\t\t\t\t\t\tif (type === 'method') {\n\t\t\t\t\t\t\tlet method = data.shift();\n\n\t\t\t\t\t\t\tif (ws['user_readonly']) {\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tlet methodLatencyId = objectIdHexString();\n\n\t\t\t\t\t\t\tLogMethodLatencies.create({\n\t\t\t\t\t\t\t\t_id: methodLatencyId,\n\t\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\t\tdate_start: new Date(),\n\t\t\t\t\t\t\t\tdate_end: null,\n\t\t\t\t\t\t\t\tlatency_ms: 0,\n\t\t\t\t\t\t\t\tmethod: method\n\t\t\t\t\t\t\t});\n\t\t\t\n\t\t\t\t\t\t\tif (method !== 'reportBuilderGetResults' && method !== 'reportBuilderGetDistinctValue' && method !== 'reportBuilderBuildTree' && method !== 'generatePDF' && method !== 'getWOOfflineData' && method !== 'countQuery' && method !== 'countWithQuery' && method !== 'countCollectionWithQuery' && method !== 'find' && method !== 'findOne' && method !== 'findWithOptions' && method !== 'getDrivers') {\n\t\t\t\t\t\t\t\tLogs.insertOne({\n\t\t\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\t\t\tid_document: '',\n\t\t\t\t\t\t\t\t\tpayload: getBinarySize(JSON.stringify(data)) < 200000 ? JSON.stringify(data, null, 2) : 'Too Big',\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tid_user: ws['id_user'] || '',\n\t\t\t\t\t\t\t\t\tuser: ws['user'] || '',\n\t\t\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\t\t\troute: messageRoute\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\n\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\tdata: 'ACK'\n\t\t\t\t\t\t\t};\n\t\t\t\n\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\tws.send(JSON.stringify(serverRes), (error) => {\n\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\n\t\t\t\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\t\t\t\t\t\tthis._methodManager.callMethod(methodLatencyId, ws, messageDate, messageId, method, ...data);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tconsole.log('Could not find method: ' + method);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (type === 'methodResponse') {\n\t\t\t\t\t\t\tlet method = data.shift();\n\t\t\t\n\t\t\t\t\t\t\tMethodResponses.findOne({$and: [\n\t\t\t\t\t\t\t\t{id_user: ws['id_user']}, \n\t\t\t\t\t\t\t\t{message_id: messageId},\n\t\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t\t{date: messageDate}\n\t\t\t\t\t\t\t]}).then(res => {\n\t\t\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\t\t\t\tws.send(JSON.stringify(res.response), (error) => {\n\t\t\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\t\t\tconsole.log('Error on WS: ', error);\n\t\t\t\t\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}, err => {});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tthis._msgQueueRunning = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}, 1);\n\t}\n\n\tpublic unsubscribeWS(ws: WebSocket) {\n\t\tthis._subscriptionManager.unsubscribeAll(ws);\n\t}\n\n\tpublic getApp() {\n\t\treturn this._app;\n\t}\n}"]}