@resolveio/server-lib 9.0.6 → 9.0.8

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.
Files changed (36) hide show
  1. package/collections/queue-method.collection.js +3 -0
  2. package/collections/queue-method.collection.js.map +1 -1
  3. package/fixtures/cron-jobs.js +13 -14
  4. package/fixtures/cron-jobs.js.map +1 -1
  5. package/managers/method.manager.js +4 -2
  6. package/managers/method.manager.js.map +1 -1
  7. package/managers/mongo.manager.d.ts +19 -19
  8. package/managers/mongo.manager.js +2 -2
  9. package/managers/mongo.manager.js.map +1 -1
  10. package/managers/monitor.manager.js +1 -0
  11. package/managers/monitor.manager.js.map +1 -1
  12. package/managers/queue-method.manager.d.ts +1 -1
  13. package/managers/queue-method.manager.js +7 -4
  14. package/managers/queue-method.manager.js.map +1 -1
  15. package/methods/accounts.js +6 -6
  16. package/methods/accounts.js.map +1 -1
  17. package/methods/aws.js.map +1 -1
  18. package/methods/collections.js +30 -15
  19. package/methods/collections.js.map +1 -1
  20. package/methods/logs.js +3 -2
  21. package/methods/logs.js.map +1 -1
  22. package/models/monitor-cpu.model.d.ts +1 -0
  23. package/models/monitor-cpu.model.js.map +1 -1
  24. package/models/monitor-https-inbound.model.d.ts +1 -0
  25. package/models/monitor-https-inbound.model.js.map +1 -1
  26. package/models/monitor-https-outbound.model.d.ts +1 -0
  27. package/models/monitor-https-outbound.model.js.map +1 -1
  28. package/models/monitor-memory.model.d.ts +1 -0
  29. package/models/monitor-memory.model.js.map +1 -1
  30. package/models/monitor-mongo.model.d.ts +1 -0
  31. package/models/monitor-mongo.model.js.map +1 -1
  32. package/models/queue-method.model.d.ts +1 -0
  33. package/models/queue-method.model.js.map +1 -1
  34. package/package.json +1 -1
  35. package/server-app.js +5 -5
  36. package/server-app.js.map +1 -1
package/methods/logs.js CHANGED
@@ -58,7 +58,8 @@ function loadLogMethods(methodManager) {
58
58
  payload: JSON.stringify(data, null, 2),
59
59
  method: '',
60
60
  user: this.user,
61
- messageId: ''
61
+ messageId: '',
62
+ route: ''
62
63
  });
63
64
  },
64
65
  skipValidation: true
@@ -86,7 +87,7 @@ function loadLogMethods(methodManager) {
86
87
  __v: 0,
87
88
  date_start: new Date(),
88
89
  date_end: null,
89
- latency: 0,
90
+ latency_ms: 0,
90
91
  method: method
91
92
  });
92
93
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/methods/logs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gEAAqD;AACrD,0FAA8E;AAC9E,kCAA2C;AAC3C,8FAAkF;AAClF,2DAA8D;AAE9D,SAAgB,cAAc,CAAC,aAA4B;IAC1D,aAAa,CAAC,OAAO,CAAC;QACrB,cAAc,EAAE;YACf,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,UAAS,OAAO,EAAE,IAAI;gBAC/B,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,uBAAe,CAAC,aAAa,EAAE,EAAE,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBAE9J,OAAO,qBAAI,CAAC,MAAM,CAAC;oBAClB,GAAG,EAAE,iCAAiB,EAAE;oBACxB,GAAG,EAAE,CAAC;oBACN,IAAI,EAAE,IAAI,IAAI,EAAE;oBAChB,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC,IAAI;oBACnC,OAAO,EAAE,OAAO;oBAChB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;oBACtC,MAAM,EAAE,EAAE;oBACV,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,SAAS,EAAE,EAAE;iBACb,CAAC,CAAC;YACJ,CAAC;YACD,cAAc,EAAE,IAAI;SACpB;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oDACD;wDACC,SAAS,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;qDAC3B;iDACD;6CACD;yCACD;wCACD;4CACC,MAAM,EAAE;gDACP,GAAG,EAAE,OAAO;gDACZ,KAAK,EAAE;oDACN,IAAI,EAAE,CAAC;iDACP;6CACD;yCACD;wCACD;4CACC,KAAK,EAAE,SAAS;yCAChB;qCACD,EAAE,EAAC,YAAY,EAAE,IAAI,EAAC,CAAC,EAAA;;gCAxBpB,eAAe,GAAG,SAwBE;gCAEL,qBAAM,8CAAgB,CAAC,SAAS,CAAC;wCACnD;4CACC,MAAM,EAAE;gDACP,IAAI,EAAE;oDACL;wDACC,SAAS,EAAE,EAAC,IAAI,EAAE,UAAU,EAAC;qDAC7B;oDACD;wDACC,SAAS,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;qDAC3B;iDACD;6CACD;yCACD;wCACD;4CACC,MAAM,EAAE;gDACP,GAAG,EAAE,OAAO;gDACZ,KAAK,EAAE;oDACN,IAAI,EAAE,CAAC;iDACP;6CACD;yCACD;wCACD;4CACC,KAAK,EAAE,SAAS;yCAChB;qCACD,EAAE,EAAC,YAAY,EAAE,IAAI,EAAC,CAAC,EAAA;;gCAxBpB,YAAY,GAAG,SAwBK;gCAExB,OAAO,CAAC;oCACP,OAAO,EAAE,SAAS;oCAClB,aAAa,EAAE,aAAa;oCAC5B,eAAe,EAAE,eAAe;oCAChC,YAAY,EAAE,YAAY;iCAC1B,CAAC,CAAC;;;;qBACH,CAAC,CAAC;YACJ,CAAC;YACD,cAAc,EAAE,IAAI;SACpB;KACD,CAAC,CAAC;AACJ,CAAC;AAnUD,wCAmUC","file":"logs.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\nimport { Logs } from '../collections/log.collection';\nimport { LogSubscriptions } from '../collections/log-subscription.collection';\nimport { ResolveIOServer } from '../index';\nimport { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport { objectIdHexString } from '../managers/mongo.manager';\n\nexport function loadLogMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tinsertErrorLog: {\n\t\t\tskipQueue: true,\n\t\t\tfunction: function(message, data) {\n\t\t\t\tthis.sendEmail('dev@resolveio.com', 'Error Detected - ' + ResolveIOServer.getClientName(), this.user + '\\n' + message + '\\n' + JSON.stringify(data, null, 2));\n\n\t\t\t\treturn Logs.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate: new Date(),\n\t\t\t\t\ttype: 'error',\n\t\t\t\t\ttitle: 'Error - User: ' + this.user,\n\t\t\t\t\tmessage: message,\n\t\t\t\t\tpayload: JSON.stringify(data, null, 2),\n\t\t\t\t\tmethod: '',\n\t\t\t\t\tuser: this.user,\n\t\t\t\t\tmessageId: ''\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertSubscriptionLog: {\n\t\t\tskipQueue: true,\n\t\t\tfunction: function(type, subscription, collection_name, subData) {\n\t\t\t\treturn LogSubscriptions.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate: new Date(),\n\t\t\t\t\ttype: type,\n\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\tsubData: subData\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertMethodLatencyLog: {\n\t\t\tskipQueue: true,\n\t\t\tfunction: function(method) {\n\t\t\t\treturn LogMethodLatencies.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate_start: new Date(),\n\t\t\t\t\tdate_end: null,\n\t\t\t\t\tlatency: 0,\n\t\t\t\t\tmethod: method\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tsuperadminAPM: {\n\t\t\tskipQueue: true,\n\t\t\tfunction: function(date_start: Date, date_end: Date, graphInterval) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet latencies = await LogMethodLatencies.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: '$method',\n\t\t\t\t\t\t\t\tmethod: {$first: '$method'},\n\t\t\t\t\t\t\t\tcount: {$sum: 1},\n\t\t\t\t\t\t\t\tlatency_min: {$min: '$latency_ms'},\n\t\t\t\t\t\t\t\tlatency_avg: {$avg: '$latency_ms'},\n\t\t\t\t\t\t\t\tlatency_max: {$max: '$latency_ms'}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true});\n\n\t\t\t\t\tlet subscriptions = await LogSubscriptions.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: '$subscription',\n\t\t\t\t\t\t\t\tsubscription: {$first: '$subscription'},\n\t\t\t\t\t\t\t\tcount: {$sum: 1}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true});\n\n\t\t\t\t\tlet groupId = {};\n\t\t\t\t\tlet groupSort = {};\n\n\t\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\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\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t\t'_id.minute': 1,\n\t\t\t\t\t\t\t'_id.second': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\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\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t\t'_id.minute': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\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\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1\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\tgroupId = {\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\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\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tlet methodGraphData = await LogMethodLatencies.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t\t$sum: 1\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\t{\n\t\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true});\n\n\t\t\t\t\tlet subGraphData = await LogSubscriptions.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t\t$sum: 1\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\t{\n\t\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true});\n\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tmethods: latencies,\n\t\t\t\t\t\tsubscriptions: subscriptions,\n\t\t\t\t\t\tmethodGraphData: methodGraphData,\n\t\t\t\t\t\tsubGraphData: subGraphData\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t}\n\t});\n}"]}
1
+ {"version":3,"sources":["../../src/methods/logs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gEAAqD;AACrD,0FAA8E;AAC9E,kCAA2C;AAC3C,8FAAkF;AAClF,2DAA8D;AAE9D,SAAgB,cAAc,CAAC,aAA4B;IAC1D,aAAa,CAAC,OAAO,CAAC;QACrB,cAAc,EAAE;YACf,SAAS,EAAE,IAAI;YACf,QAAQ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AAI,EAAE,QAAQ,EAAC;qDAC3B;iDACD;6CACD;yCACD;wCACD;4CACC,MAAM,EAAE;gDACP,GAAG,EAAE,OAAO;gDACZ,KAAK,EAAE;oDACN,IAAI,EAAE,CAAC;iDACP;6CACD;yCACD;wCACD;4CACC,KAAK,EAAE,SAAS;yCAChB;qCACD,EAAE,EAAC,YAAY,EAAE,IAAI,EAAC,CAAC,EAAA;;gCAxBpB,YAAY,GAAG,SAwBK;gCAExB,OAAO,CAAC;oCACP,OAAO,EAAE,SAAS;oCAClB,aAAa,EAAE,aAAa;oCAC5B,eAAe,EAAE,eAAe;oCAChC,YAAY,EAAE,YAAY;iCAC1B,CAAC,CAAC;;;;qBACH,CAAC,CAAC;YACJ,CAAC;YACD,cAAc,EAAE,IAAI;SACpB;KACD,CAAC,CAAC;AACJ,CAAC;AApUD,wCAoUC","file":"logs.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\nimport { Logs } from '../collections/log.collection';\nimport { LogSubscriptions } from '../collections/log-subscription.collection';\nimport { ResolveIOServer } from '../index';\nimport { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport { objectIdHexString } from '../managers/mongo.manager';\n\nexport function loadLogMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tinsertErrorLog: {\n\t\t\tskipQueue: true,\n\t\t\tfunction: function(message, data) {\n\t\t\t\tthis.sendEmail('dev@resolveio.com', 'Error Detected - ' + ResolveIOServer.getClientName(), this.user + '\\n' + message + '\\n' + JSON.stringify(data, null, 2));\n\n\t\t\t\treturn Logs.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate: new Date(),\n\t\t\t\t\ttype: 'error',\n\t\t\t\t\ttitle: 'Error - User: ' + this.user,\n\t\t\t\t\tmessage: message,\n\t\t\t\t\tpayload: JSON.stringify(data, null, 2),\n\t\t\t\t\tmethod: '',\n\t\t\t\t\tuser: this.user,\n\t\t\t\t\tmessageId: '',\n\t\t\t\t\troute: ''\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertSubscriptionLog: {\n\t\t\tskipQueue: true,\n\t\t\tfunction: function(type, subscription, collection_name, subData) {\n\t\t\t\treturn LogSubscriptions.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate: new Date(),\n\t\t\t\t\ttype: type,\n\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\tsubData: subData\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertMethodLatencyLog: {\n\t\t\tskipQueue: true,\n\t\t\tfunction: function(method) {\n\t\t\t\treturn LogMethodLatencies.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate_start: new Date(),\n\t\t\t\t\tdate_end: null,\n\t\t\t\t\tlatency_ms: 0,\n\t\t\t\t\tmethod: method\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tsuperadminAPM: {\n\t\t\tskipQueue: true,\n\t\t\tfunction: function(date_start: Date, date_end: Date, graphInterval) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet latencies = await LogMethodLatencies.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: '$method',\n\t\t\t\t\t\t\t\tmethod: {$first: '$method'},\n\t\t\t\t\t\t\t\tcount: {$sum: 1},\n\t\t\t\t\t\t\t\tlatency_min: {$min: '$latency_ms'},\n\t\t\t\t\t\t\t\tlatency_avg: {$avg: '$latency_ms'},\n\t\t\t\t\t\t\t\tlatency_max: {$max: '$latency_ms'}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true});\n\n\t\t\t\t\tlet subscriptions = await LogSubscriptions.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: '$subscription',\n\t\t\t\t\t\t\t\tsubscription: {$first: '$subscription'},\n\t\t\t\t\t\t\t\tcount: {$sum: 1}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true});\n\n\t\t\t\t\tlet groupId = {};\n\t\t\t\t\tlet groupSort = {};\n\n\t\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\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\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t\t'_id.minute': 1,\n\t\t\t\t\t\t\t'_id.second': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\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\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t\t'_id.minute': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\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\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1\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\tgroupId = {\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\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\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tlet methodGraphData = await LogMethodLatencies.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t\t$sum: 1\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\t{\n\t\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true});\n\n\t\t\t\t\tlet subGraphData = await LogSubscriptions.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\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\t\tcreatedAt: {$lte: date_end}\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\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t\t$sum: 1\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\t{\n\t\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true});\n\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tmethods: latencies,\n\t\t\t\t\t\tsubscriptions: subscriptions,\n\t\t\t\t\t\tmethodGraphData: methodGraphData,\n\t\t\t\t\t\tsubGraphData: subGraphData\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t}\n\t});\n}"]}
@@ -1,5 +1,6 @@
1
1
  import { CollectionDocument } from './collection-document.model';
2
2
  export interface MonitorCPUModel extends CollectionDocument {
3
+ instance: string;
3
4
  client: string;
4
5
  date: Date;
5
6
  app: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/models/monitor-cpu.model.ts"],"names":[],"mappings":"","file":"monitor-cpu.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface MonitorCPUModel extends CollectionDocument {\n\tclient: string;\n\tdate: Date;\n\tapp: number;\n\tsystem: number;\n}"]}
1
+ {"version":3,"sources":["../../src/models/monitor-cpu.model.ts"],"names":[],"mappings":"","file":"monitor-cpu.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface MonitorCPUModel extends CollectionDocument {\n\tinstance: string;\n\tclient: string;\n\tdate: Date;\n\tapp: number;\n\tsystem: number;\n}"]}
@@ -1,5 +1,6 @@
1
1
  import { CollectionDocument } from './collection-document.model';
2
2
  export interface MonitorHTTPSInboundModel extends CollectionDocument {
3
+ instance: string;
3
4
  client: string;
4
5
  date: Date;
5
6
  method: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/models/monitor-https-inbound.model.ts"],"names":[],"mappings":"","file":"monitor-https-inbound.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface MonitorHTTPSInboundModel extends CollectionDocument {\n\tclient: string;\n\tdate: Date;\n\tmethod: string;\n\turl: string;\n\tduration: number;\n\tcontentType: string;\n\trequestHeader: string;\n}"]}
1
+ {"version":3,"sources":["../../src/models/monitor-https-inbound.model.ts"],"names":[],"mappings":"","file":"monitor-https-inbound.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface MonitorHTTPSInboundModel extends CollectionDocument {\n\tinstance: string;\n\tclient: string;\n\tdate: Date;\n\tmethod: string;\n\turl: string;\n\tduration: number;\n\tcontentType: string;\n\trequestHeader: string;\n}"]}
@@ -1,5 +1,6 @@
1
1
  import { CollectionDocument } from './collection-document.model';
2
2
  export interface MonitorHTTPSOutboundModel extends CollectionDocument {
3
+ instance: string;
3
4
  client: string;
4
5
  date: Date;
5
6
  method: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/models/monitor-https-outbound.model.ts"],"names":[],"mappings":"","file":"monitor-https-outbound.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface MonitorHTTPSOutboundModel extends CollectionDocument {\n\tclient: string;\n\tdate: Date;\n\tmethod: string;\n\turl: string;\n\tduration: number;\n\tstatus: string;\n\tcontentType: string;\n\trequestHeaders: Object;\n}"]}
1
+ {"version":3,"sources":["../../src/models/monitor-https-outbound.model.ts"],"names":[],"mappings":"","file":"monitor-https-outbound.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface MonitorHTTPSOutboundModel extends CollectionDocument {\n\tinstance: string;\n\tclient: string;\n\tdate: Date;\n\tmethod: string;\n\turl: string;\n\tduration: number;\n\tstatus: string;\n\tcontentType: string;\n\trequestHeaders: Object;\n}"]}
@@ -1,5 +1,6 @@
1
1
  import { CollectionDocument } from './collection-document.model';
2
2
  export interface MonitorMemoryModel extends CollectionDocument {
3
+ instance: string;
3
4
  client: string;
4
5
  date: Date;
5
6
  physical_total: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/models/monitor-memory.model.ts"],"names":[],"mappings":"","file":"monitor-memory.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface MonitorMemoryModel extends CollectionDocument {\n\tclient: string;\n\tdate: Date;\n\tphysical_total: number;\n\tphysical_used: number;\n\tphysical_free: number;\n\tvirtual: number;\n\tprivate: number;\n\tphysical: number;\n}"]}
1
+ {"version":3,"sources":["../../src/models/monitor-memory.model.ts"],"names":[],"mappings":"","file":"monitor-memory.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface MonitorMemoryModel extends CollectionDocument {\n\tinstance: string;\n\tclient: string;\n\tdate: Date;\n\tphysical_total: number;\n\tphysical_used: number;\n\tphysical_free: number;\n\tvirtual: number;\n\tprivate: number;\n\tphysical: number;\n}"]}
@@ -1,5 +1,6 @@
1
1
  import { CollectionDocument } from './collection-document.model';
2
2
  export interface MonitorMongoModel extends CollectionDocument {
3
+ instance: string;
3
4
  client: string;
4
5
  date: Date;
5
6
  method: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/models/monitor-mongo.model.ts"],"names":[],"mappings":"","file":"monitor-mongo.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface MonitorMongoModel extends CollectionDocument {\n\tclient: string;\n\tdate: Date;\n\tmethod: string;\n\tdoc_collection: string;\n\tduration: number;\n\tquery: string;\n}"]}
1
+ {"version":3,"sources":["../../src/models/monitor-mongo.model.ts"],"names":[],"mappings":"","file":"monitor-mongo.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface MonitorMongoModel extends CollectionDocument {\n\tinstance: string;\n\tclient: string;\n\tdate: Date;\n\tmethod: string;\n\tdoc_collection: string;\n\tduration: number;\n\tquery: string;\n}"]}
@@ -2,6 +2,7 @@ import { CollectionDocument } from './collection-document.model';
2
2
  export interface QueueMethodModel extends CollectionDocument {
3
3
  method: string;
4
4
  method_data: any[];
5
+ method_data_string: string;
5
6
  id_ws: string;
6
7
  messageId: number;
7
8
  id_user: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/models/queue-method.model.ts"],"names":[],"mappings":"","file":"queue-method.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface QueueMethodModel extends CollectionDocument {\n\tmethod: string;\n\tmethod_data: any[];\n\tid_ws: string;\n\tmessageId: number;\n\tid_user: string;\n\tuser: string;\n\tdate: Date;\n\tid_methodLatency: string;\n}"]}
1
+ {"version":3,"sources":["../../src/models/queue-method.model.ts"],"names":[],"mappings":"","file":"queue-method.model.js","sourcesContent":["import { CollectionDocument } from './collection-document.model';\n\nexport interface QueueMethodModel extends CollectionDocument {\n\tmethod: string;\n\tmethod_data: any[];\n\tmethod_data_string: string;\n\tid_ws: string;\n\tmessageId: number;\n\tid_user: string;\n\tuser: string;\n\tdate: Date;\n\tid_methodLatency: string;\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "9.0.6",
3
+ "version": "9.0.8",
4
4
  "description": "",
5
5
  "main": "index.ts",
6
6
  "scripts": {
package/server-app.js CHANGED
@@ -573,7 +573,7 @@ var ResolveIOMainServer = /** @class */ (function () {
573
573
  payload: JSON.stringify(data, null, 2),
574
574
  method: method,
575
575
  user: ws['user'],
576
- messageId: messageId,
576
+ messageId: messageId.toString(),
577
577
  route: messageRoute,
578
578
  data_0: data[0] ? JSON.stringify(data[0]) : null,
579
579
  data_1: data[1] ? JSON.stringify(data[1]) : null,
@@ -589,7 +589,7 @@ var ResolveIOMainServer = /** @class */ (function () {
589
589
  payload: 'Too Big',
590
590
  method: method,
591
591
  user: ws['user'],
592
- messageId: messageId,
592
+ messageId: messageId.toString(),
593
593
  route: messageRoute,
594
594
  data_0: null,
595
595
  data_1: null
@@ -644,7 +644,7 @@ var ResolveIOMainServer = /** @class */ (function () {
644
644
  _id: mongo_manager_1.objectIdHexString(),
645
645
  __v: 0,
646
646
  id_user: ws['id_user'],
647
- message_id: messageId,
647
+ message_id: messageId.toString(),
648
648
  method: method,
649
649
  date: messageDate
650
650
  });
@@ -663,7 +663,7 @@ var ResolveIOMainServer = /** @class */ (function () {
663
663
  else {
664
664
  method_response_collection_1.MethodResponses.findOne({ $and: [
665
665
  { id_user: ws['id_user'] },
666
- { message_id: messageId },
666
+ { message_id: messageId.toString() },
667
667
  { method: method },
668
668
  { date: messageDate }
669
669
  ] }).then(function (res) {
@@ -689,7 +689,7 @@ var ResolveIOMainServer = /** @class */ (function () {
689
689
  method = data.shift();
690
690
  method_response_collection_1.MethodResponses.findOne({ $and: [
691
691
  { id_user: ws['id_user'] },
692
- { message_id: messageId },
692
+ { message_id: messageId.toString() },
693
693
  { method: method },
694
694
  { date: messageDate }
695
695
  ] }).then(function (res) {
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,mCAAqC;AACrC,8CAAgD;AAChD,8BAAgC;AAChC,kCAAoC;AACpC,8BAAgC;AAChC,kDAAoD;AACpD,+BAAiC;AAEjC,wCAAqE;AAErE,0DAA2E;AAC3E,wDAAsD;AACtD,4DAA0D;AAC1D,wEAAsE;AACtE,wEAAqE;AACrE,8DAA4D;AAI5D,+EAAmE;AACnE,uFAA2E;AAC3E,+DAAoD;AACpD,6FAAiF;AACjF,iEAAsD;AAEtD,oCAA8C;AAC9C,oCAA8C;AAC9C,wCAAkD;AAElD;IAyBC,6BAAY,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe;QAArG,iBAgLC;QAlMO,cAAS,GAAG,EAAE,CAAC;QACf,qBAAgB,GAAG,KAAK,CA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iDACnB,EAAC,CAAC,CAAC,IAAI,CAAC,UAAA,GAAG;gDACX,IAAI,GAAG,EAAE;oDACR,IAAI,EAAE,IAAI,EAAE,CAAC,UAAU,KAAK,EAAE,CAAC,IAAI,EAAE;wDACpC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,UAAC,KAAK;4DAC3C,IAAI,KAAK,EAAE;gEACV,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;gEACpC,KAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;6DACvB;wDACF,CAAC,CAAC,CAAC;qDACH;iDACD;4CACF,CAAC,EAAE,UAAA,GAAG,IAAK,CAAC,CAAC,CAAC;yCACd;;;;;;;wBA3LO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;;;6BAAE,CAAA,CAAC,IAAI,CAAC,CAAA;sDAArC,CAAC;;;;;wBAAsC,CAAC,EAAE,CAAA;;;wBA8LnD,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;;;;;aAE/B,EAAE,EAAE,CAAC,CAAC;IACR,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,CArsBA,AAqsBC,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 passport from 'passport';\nimport * as passportlocal from 'passport-local';\nimport * as WebSocket from 'ws';\nimport * as jwt from 'jsonwebtoken';\nimport * as uuid from 'uuid/v4';\nimport * as SegfaultHandler from 'segfault-handler';\nimport * as moment from 'moment';\n\nimport { dateReviver, getBinarySize, deepCopy } from './util/common';\n\nimport { objectIdHexString, MongoManager } from './managers/mongo.manager';\nimport { CronManager } from './managers/cron.manager';\nimport { MethodManager } from './managers/method.manager';\nimport { SubscriptionManager } from './managers/subscription.manager';\nimport { QueueMethodManager } from './managers/queue-method.manager';\nimport { MonitorManager } from './managers/monitor.manager';\n\nimport { ServerResponseModel } from './models/server-response.model';\n\nimport { MethodCalls } from './collections/method-call.collection';\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';\n\nexport default class ResolveIOMainServer {\n\tprivate _app: express.Application;\n\tprivate _server: Server;\n\tprivate _port: string | number;\n\tprivate _wss;\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 _mongoManager: MongoManager;\n\tprivate _monitorManager: MonitorManager;\n\tprivate _subscriptionManager: SubscriptionManager;\n\tprivate _methodManager: MethodManager;\n\tprivate _queueManager: QueueMethodManager;\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\n\t\tthis._mongoManager = new MongoManager(mainServer);\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('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'] === 'MissingSchemaError') {\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') {\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\tlet res = null;\n\n\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\tif (ws['id_socket'] === id_ws) {\n\t\t\t\tres = ws;\n\t\t\t}\n\t\t});\n\n\t\treturn res;\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 getQueueManager() {\n\t\treturn this._queueManager;\n\t}\n\n\tpublic getMonitorManager() {\n\t\treturn this._monitorManager;\n\t}\n\n\tpublic getMongoServer() {\n\t\treturn this._mongoManager;\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\tthis.setUpPassport();\n\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\t\tthis._queueManager = new QueueMethodManager(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\tprivate setUpPassport(): void {\n\t\tif (Users) {\n\t\t\t// Set up login passort\n\t\t\tthis._app.use(passport.initialize());\n\n\t\t\t// Start user authentication\n\t\t\tpassport.use(new passportlocal.Strategy(Users.authenticateStrategy()));\n\t\t\tpassport.serializeUser(Users.serializeUser());\n\t\t\tpassport.deserializeUser(Users.deserializeUser());\n\t\t}\n\t\telse {\n\t\t\tsetTimeout(() => {\n\t\t\t\tthis.setUpPassport();\n\t\t\t}, 0);\n\t\t}\n\t}\n\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', (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\tws['id_socket'] = uuid();\n\t\t\tws['retryCnt'] = 0;\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}, 10000);\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 = null;\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\tlet data = deepCopy(socketData);\n\n\t\t\t\t\tif (data[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 = data.shift();\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 = data.shift();\n\t\t\t\t\tlet messageId = data.shift();\n\t\t\t\t\tlet type = data.shift();\n\n\t\t\t\t\tif (type === 'subscription') {\n\t\t\t\t\t\tlet subType = data.shift();\n\t\t\t\t\t\tlet pub = data.shift();\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, ...data);\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, ...data);\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(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}, 5000);\n\n\t\tsetInterval(async () => {\n\t\t\t// console.log(data);\n\n\t\t\tif (!this._msgQueueRunning) {\n\t\t\t\tthis._msgQueueRunning = true;\n\t\t\t\t\n\t\t\t\tfor (let i = this._msgQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\tlet msg = this._msgQueue.pop();\n\t\t\t\t\tlet data = msg.data;\n\t\t\t\t\tlet ws = msg.ws;\n\t\t\n\t\t\t\t\tlet messageRoute = data.shift();\n\t\t\t\t\tlet messageDate = data.shift();\n\t\t\t\t\tlet messageId = data.shift();\n\t\t\t\t\tlet type = data.shift();\n\t\t\n\t\t\t\t\t// Method call\n\t\t\t\t\tif (type === 'method') {\n\t\t\t\t\t\tlet method = data.shift();\n\t\t\n\t\t\t\t\t\tif (method === 'setWSAppVersion') {\n\t\t\t\t\t\t\tclearTimeout(ws['versionTimer']);\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\tif (method === 'disconnectWSCommand') {\n\t\t\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t}, 5000);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (ws['user_readonly']) {\n\t\t\t\t\t\t\tcontinue;\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 (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\tif (getBinarySize(JSON.stringify(data)) < 200000) {\n\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\ttitle: 'Client Request - Method',\n\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method + ', Route: ' + messageRoute,\n\t\t\t\t\t\t\t\t\tpayload: JSON.stringify(data, null, 2),\n\t\t\t\t\t\t\t\t\tmethod: method,\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\tdata_0: data[0] ? JSON.stringify(data[0]) : null,\n\t\t\t\t\t\t\t\t\tdata_1: data[1] ? JSON.stringify(data[1]) : null,\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\tLogs.create({\n\t\t\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\ttitle: 'Client Request - Method',\n\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method + ', Route: ' + messageRoute,\n\t\t\t\t\t\t\t\t\tpayload: 'Too Big',\n\t\t\t\t\t\t\t\t\tmethod: method,\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\tdata_0: null,\n\t\t\t\t\t\t\t\t\tdata_1: null\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\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\t\t\n\t\t\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\n\t\t\t\t\t\t\tlet query: any = {$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{date: messageDate}\n\t\t\t\t\t\t\t]};\n\t\t\n\t\t\t\t\t\t\tif (method !== 'updateDocumentOffline' && method !== 'updateDocumentPropsOffline') {\n\t\t\t\t\t\t\t\tquery.$and.push({method: method});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tif (method === 'updateDocumentOffline') {\n\t\t\t\t\t\t\t\t\tquery.$and.push({\n\t\t\t\t\t\t\t\t\t\t$or: [\n\t\t\t\t\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t\t\t\t\t{method: 'updateDocument'}\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\telse if (method === 'updateDocumentPropsOffline') {\n\t\t\t\t\t\t\t\t\tquery.$and.push({\n\t\t\t\t\t\t\t\t\t\t$or: [\n\t\t\t\t\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t\t\t\t\t{method: 'updateDocumentProps'}\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}\n\t\t\n\t\t\t\t\t\t\tlet methodCall = await MethodCalls.findOne(query);\n\t\t\n\t\t\t\t\t\t\tif (!methodCall) {\n\t\t\t\t\t\t\t\tMethodCalls.create({\n\t\t\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\t\t\t\tmessage_id: messageId,\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tdate: messageDate\n\t\t\t\t\t\t\t\t});\n\t\t\t\n\t\t\t\t\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\t\t\t\t\t\t\tif (this._methodManager._methods[method].skipQueue) {\n\t\t\t\t\t\t\t\t\t\tthis._methodManager.callMethod(methodLatencyId, ws, messageDate, messageId, method, ...data);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tthis._queueManager.addMethodToQueue(methodLatencyId, ws['id_socket'], ws['id_user'], ws['user'], messageDate, messageId, method, data);\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\telse {\n\t\t\t\t\t\t\t\t\tconsole.log('Could not find method: ' + method);\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\tMethodResponses.findOne({$and: [\n\t\t\t\t\t\t\t\t\t{id_user: ws['id_user']}, \n\t\t\t\t\t\t\t\t\t{message_id: messageId},\n\t\t\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t\t\t{date: messageDate}\n\t\t\t\t\t\t\t\t]}).then(res => {\n\t\t\t\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\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\t\tif (error) {\n\t\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\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t\t\t\t}\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}, err => {});\n\t\t\t\t\t\t\t}\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 if (type === 'methodResponse') {\n\t\t\t\t\t\tlet method = data.shift();\n\t\t\n\t\t\t\t\t\tMethodResponses.findOne({$and: [\n\t\t\t\t\t\t\t{id_user: ws['id_user']}, \n\t\t\t\t\t\t\t{message_id: messageId},\n\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t{date: messageDate}\n\t\t\t\t\t\t]}).then(res => {\n\t\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\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\tif (error) {\n\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\tthis.unsubscribeWS(ws);\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}\n\t\t\t\t\t\t}, err => {});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis._msgQueueRunning = false;\n\t\t\t}\n\t\t}, 25);\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA4C;AAC5C,iCAAmC;AACnC,wCAA0C;AAC1C,kDAAoD;AACpD,mCAAqC;AACrC,8CAAgD;AAChD,8BAAgC;AAChC,kCAAoC;AACpC,8BAAgC;AAChC,kDAAoD;AACpD,+BAAiC;AAEjC,wCAAqE;AAErE,0DAA2E;AAC3E,wDAAsD;AACtD,4DAA0D;AAC1D,wEAAsE;AACtE,wEAAqE;AACrE,8DAA4D;AAI5D,+EAAmE;AACnE,uFAA2E;AAC3E,+DAAoD;AACpD,6FAAiF;AACjF,iEAAsD;AAEtD,oCAA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ArsBA,AAqsBC,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 passport from 'passport';\nimport * as passportlocal from 'passport-local';\nimport * as WebSocket from 'ws';\nimport * as jwt from 'jsonwebtoken';\nimport * as uuid from 'uuid/v4';\nimport * as SegfaultHandler from 'segfault-handler';\nimport * as moment from 'moment';\n\nimport { dateReviver, getBinarySize, deepCopy } from './util/common';\n\nimport { objectIdHexString, MongoManager } from './managers/mongo.manager';\nimport { CronManager } from './managers/cron.manager';\nimport { MethodManager } from './managers/method.manager';\nimport { SubscriptionManager } from './managers/subscription.manager';\nimport { QueueMethodManager } from './managers/queue-method.manager';\nimport { MonitorManager } from './managers/monitor.manager';\n\nimport { ServerResponseModel } from './models/server-response.model';\n\nimport { MethodCalls } from './collections/method-call.collection';\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';\n\nexport default class ResolveIOMainServer {\n\tprivate _app: express.Application;\n\tprivate _server: Server;\n\tprivate _port: string | number;\n\tprivate _wss;\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 _mongoManager: MongoManager;\n\tprivate _monitorManager: MonitorManager;\n\tprivate _subscriptionManager: SubscriptionManager;\n\tprivate _methodManager: MethodManager;\n\tprivate _queueManager: QueueMethodManager;\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\n\t\tthis._mongoManager = new MongoManager(mainServer);\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('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'] === 'MissingSchemaError') {\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') {\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\tlet res = null;\n\n\t\tthis._wss.clients.forEach((ws: WebSocket) => {\n\t\t\tif (ws['id_socket'] === id_ws) {\n\t\t\t\tres = ws;\n\t\t\t}\n\t\t});\n\n\t\treturn res;\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 getQueueManager() {\n\t\treturn this._queueManager;\n\t}\n\n\tpublic getMonitorManager() {\n\t\treturn this._monitorManager;\n\t}\n\n\tpublic getMongoServer() {\n\t\treturn this._mongoManager;\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\tthis.setUpPassport();\n\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\t\tthis._queueManager = new QueueMethodManager(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\tprivate setUpPassport(): void {\n\t\tif (Users) {\n\t\t\t// Set up login passort\n\t\t\tthis._app.use(passport.initialize());\n\n\t\t\t// Start user authentication\n\t\t\tpassport.use(new passportlocal.Strategy(Users.authenticateStrategy()));\n\t\t\tpassport.serializeUser(Users.serializeUser());\n\t\t\tpassport.deserializeUser(Users.deserializeUser());\n\t\t}\n\t\telse {\n\t\t\tsetTimeout(() => {\n\t\t\t\tthis.setUpPassport();\n\t\t\t}, 0);\n\t\t}\n\t}\n\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', (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\tws['id_socket'] = uuid();\n\t\t\tws['retryCnt'] = 0;\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}, 10000);\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 = null;\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\tlet data = deepCopy(socketData);\n\n\t\t\t\t\tif (data[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 = data.shift();\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 = data.shift();\n\t\t\t\t\tlet messageId = data.shift();\n\t\t\t\t\tlet type = data.shift();\n\n\t\t\t\t\tif (type === 'subscription') {\n\t\t\t\t\t\tlet subType = data.shift();\n\t\t\t\t\t\tlet pub = data.shift();\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, ...data);\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, ...data);\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(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}, 5000);\n\n\t\tsetInterval(async () => {\n\t\t\t// console.log(data);\n\n\t\t\tif (!this._msgQueueRunning) {\n\t\t\t\tthis._msgQueueRunning = true;\n\t\t\t\t\n\t\t\t\tfor (let i = this._msgQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\tlet msg = this._msgQueue.pop();\n\t\t\t\t\tlet data = msg.data;\n\t\t\t\t\tlet ws = msg.ws;\n\t\t\n\t\t\t\t\tlet messageRoute: string = data.shift();\n\t\t\t\t\tlet messageDate: Date = data.shift();\n\t\t\t\t\tlet messageId: number = data.shift();\n\t\t\t\t\tlet type: string = data.shift();\n\t\t\n\t\t\t\t\t// Method call\n\t\t\t\t\tif (type === 'method') {\n\t\t\t\t\t\tlet method = data.shift();\n\t\t\n\t\t\t\t\t\tif (method === 'setWSAppVersion') {\n\t\t\t\t\t\t\tclearTimeout(ws['versionTimer']);\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\tif (method === 'disconnectWSCommand') {\n\t\t\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t}, 5000);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (ws['user_readonly']) {\n\t\t\t\t\t\t\tcontinue;\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 (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\tif (getBinarySize(JSON.stringify(data)) < 200000) {\n\t\t\t\t\t\t\t\tLogs.create({\n\t\t\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\ttitle: 'Client Request - Method',\n\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method + ', Route: ' + messageRoute,\n\t\t\t\t\t\t\t\t\tpayload: JSON.stringify(data, null, 2),\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\tmessageId: messageId.toString(),\n\t\t\t\t\t\t\t\t\troute: messageRoute,\n\t\t\t\t\t\t\t\t\tdata_0: data[0] ? JSON.stringify(data[0]) : null,\n\t\t\t\t\t\t\t\t\tdata_1: data[1] ? JSON.stringify(data[1]) : null,\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\tLogs.create({\n\t\t\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t\t\tdate: new Date(),\n\t\t\t\t\t\t\t\t\ttype: 'client-request',\n\t\t\t\t\t\t\t\t\ttitle: 'Client Request - Method',\n\t\t\t\t\t\t\t\t\tmessage: 'User: ' + ws['user'] + ', Type: ' + type + ', MessageId: ' + messageId + ', Method: ' + method + ', Route: ' + messageRoute,\n\t\t\t\t\t\t\t\t\tpayload: 'Too Big',\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\t\t\t\t\tmessageId: messageId.toString(),\n\t\t\t\t\t\t\t\t\troute: messageRoute,\n\t\t\t\t\t\t\t\t\tdata_0: null,\n\t\t\t\t\t\t\t\t\tdata_1: null\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\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\t\t\n\t\t\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\n\t\t\t\t\t\t\tlet query: any = {$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{date: messageDate}\n\t\t\t\t\t\t\t]};\n\t\t\n\t\t\t\t\t\t\tif (method !== 'updateDocumentOffline' && method !== 'updateDocumentPropsOffline') {\n\t\t\t\t\t\t\t\tquery.$and.push({method: method});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tif (method === 'updateDocumentOffline') {\n\t\t\t\t\t\t\t\t\tquery.$and.push({\n\t\t\t\t\t\t\t\t\t\t$or: [\n\t\t\t\t\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t\t\t\t\t{method: 'updateDocument'}\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\telse if (method === 'updateDocumentPropsOffline') {\n\t\t\t\t\t\t\t\t\tquery.$and.push({\n\t\t\t\t\t\t\t\t\t\t$or: [\n\t\t\t\t\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t\t\t\t\t{method: 'updateDocumentProps'}\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}\n\t\t\n\t\t\t\t\t\t\tlet methodCall = await MethodCalls.findOne(query);\n\t\t\n\t\t\t\t\t\t\tif (!methodCall) {\n\t\t\t\t\t\t\t\tMethodCalls.create({\n\t\t\t\t\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t\t\t\t\t__v: 0,\n\t\t\t\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\t\t\t\tmessage_id: messageId.toString(),\n\t\t\t\t\t\t\t\t\tmethod: method,\n\t\t\t\t\t\t\t\t\tdate: messageDate\n\t\t\t\t\t\t\t\t});\n\t\t\t\n\t\t\t\t\t\t\t\tif (this._methodManager._methods[method]) {\n\t\t\t\t\t\t\t\t\tif (this._methodManager._methods[method].skipQueue) {\n\t\t\t\t\t\t\t\t\t\tthis._methodManager.callMethod(methodLatencyId, ws, messageDate, messageId, method, ...data);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tthis._queueManager.addMethodToQueue(methodLatencyId, ws['id_socket'], ws['id_user'], ws['user'], messageDate, messageId, method, data);\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\telse {\n\t\t\t\t\t\t\t\t\tconsole.log('Could not find method: ' + method);\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\tMethodResponses.findOne({$and: [\n\t\t\t\t\t\t\t\t\t{id_user: ws['id_user']}, \n\t\t\t\t\t\t\t\t\t{message_id: messageId.toString()},\n\t\t\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t\t\t{date: messageDate}\n\t\t\t\t\t\t\t\t]}).then(res => {\n\t\t\t\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\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\t\tif (error) {\n\t\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\t\tthis.unsubscribeWS(ws);\n\t\t\t\t\t\t\t\t\t\t\t\t}\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}, err => {});\n\t\t\t\t\t\t\t}\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 if (type === 'methodResponse') {\n\t\t\t\t\t\tlet method = data.shift();\n\t\t\n\t\t\t\t\t\tMethodResponses.findOne({$and: [\n\t\t\t\t\t\t\t{id_user: ws['id_user']}, \n\t\t\t\t\t\t\t{message_id: messageId.toString()},\n\t\t\t\t\t\t\t{method: method},\n\t\t\t\t\t\t\t{date: messageDate}\n\t\t\t\t\t\t]}).then(res => {\n\t\t\t\t\t\t\tif (res) {\n\t\t\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\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\tif (error) {\n\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\tthis.unsubscribeWS(ws);\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}\n\t\t\t\t\t\t}, err => {});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis._msgQueueRunning = false;\n\t\t\t}\n\t\t}, 25);\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}"]}