chat-platform 2.1.4 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "globals": {
3
- "Promise": true
3
+ "Promise": true,
4
+ "fetch": true,
5
+ "URLSearchParams": true
4
6
  },
5
7
  "env": {
6
8
  "node": true,
@@ -1,4 +1,3 @@
1
- const moment = require('moment');
2
1
  const assert = require('chai').assert;
3
2
  const RED = require('../lib/red-stub')();
4
3
  const ChatExpress = require('../chat-platform');
@@ -79,7 +78,7 @@ describe('Chat platform framework', () => {
79
78
  chatIdKey: payload => payload.myChatIdKey,
80
79
  userIdKey: payload => payload.myUserIdKey,
81
80
  type: payload => payload.type,
82
- tsKey: () => moment(),
81
+ tsKey: () => new Date(),
83
82
  transport: 'generic',
84
83
  inboundMessageEvent: 'message',
85
84
  connector: connector,
@@ -103,7 +102,8 @@ describe('Chat platform framework', () => {
103
102
  assert.equal(message.payload.userId, '62');
104
103
  assert.equal(message.payload.inbound, true);
105
104
  assert.equal(message.payload.transport, 'generic');
106
- assert.equal(message.payload.ts.isValid(), true);
105
+ assert.instanceOf(message.payload.ts, Date);
106
+ assert.isFalse(isNaN(message.payload.ts.getTime()));
107
107
  assert.isFunction(message.chat);
108
108
  const variables = message.chat().all();
109
109
  assert.equal(variables.pending, false);
@@ -1,4 +1,4 @@
1
- const _ = require('underscore');
1
+ const _ = require('lodash');
2
2
  const assert = require('chai').assert;
3
3
  const fs = require('fs');
4
4
  const os = require('os');
@@ -1,4 +1,4 @@
1
- const _ = require('underscore');
1
+ const _ = require('lodash');
2
2
  const assert = require('chai').assert;
3
3
  const fs = require('fs');
4
4
  const os = require('os');
@@ -1,4 +1,3 @@
1
- const moment = require('moment');
2
1
  const chai = require('chai');
3
2
  const assert = chai.assert;
4
3
  const expect = chai.expect;
@@ -114,7 +113,7 @@ describe('Universal Connector', () => {
114
113
  assert.equal(variables.payload, 'Bazinga');
115
114
  assert.equal(variables.authorized, false);
116
115
  assert.equal(variables.language, 'it');
117
- assert.instanceOf(message.payload.ts, moment);
116
+ assert.instanceOf(message.payload.ts, Date);
118
117
  done();
119
118
  });
120
119
  chatServer.receive({
@@ -1,4 +1,4 @@
1
- const _ = require('underscore');
1
+ const _ = require('lodash');
2
2
 
3
3
  const contextProviders = {};
4
4
  contextProviders.memory = require('./providers/memory');
@@ -59,7 +59,7 @@ const ContextProviders = function(RED) {
59
59
  },
60
60
 
61
61
  hasProvider(provider) {
62
- return _(methods.getProviders()).contains(provider);
62
+ return _.includes(methods.getProviders(), provider);
63
63
  },
64
64
 
65
65
  getProvider(providerName, params = {}) {
package/chat-log.js CHANGED
@@ -1,5 +1,4 @@
1
- var _ = require('underscore');
2
- var moment = require('moment');
1
+ var _ = require('lodash');
3
2
  var fs = require('fs');
4
3
  var lcd = require('./helpers/lcd');
5
4
 
@@ -103,7 +102,7 @@ module.exports = function(variables) {
103
102
  + (!_.isEmpty(name) ? '[' + name.join(' ') + '] ' : '')
104
103
  + (inbound ? '> ' : '< ')
105
104
  + (transport != null ? '[' + transport.toUpperCase() + '] ' : '')
106
- + moment().toString() + ' - ' + stringifiedMessage;
105
+ + new Date().toString() + ' - ' + stringifiedMessage;
107
106
  }
108
107
  }
109
108
 
package/chat-platform.js CHANGED
@@ -1,5 +1,4 @@
1
- const _ = require('underscore');
2
- const _s = require('underscore.string');
1
+ const _ = require('lodash');
3
2
  const clc = require('cli-color');
4
3
  const prettyjson = require('prettyjson');
5
4
  const { when } = require('./lib/utils');
@@ -7,7 +6,6 @@ const EventEmitter = require('events').EventEmitter;
7
6
  const inherits = require('util').inherits;
8
7
  const lcd = require('./helpers/lcd');
9
8
  const Table = require('cli-table');
10
- const request = require('request').defaults({ encoding: null });
11
9
 
12
10
  const identity = function(obj) { return obj; };
13
11
  const green = clc.greenBright;
@@ -541,11 +539,13 @@ const ChatExpress = function(options) {
541
539
  var options = chatServer.getOptions();
542
540
  var connector = options.connector;
543
541
  if (connector != null) {
544
- if (options.inboundMessageEvent != null) {
542
+ if (_.isFunction(options.inboundMessageEvent)) {
545
543
  connector.off(options.inboundMessageEvent);
546
544
  }
547
545
  _(events).each(function (callback, eventName) {
548
- connector.off(eventName);
546
+ if (_.isFunction(eventName)) {
547
+ connector.off(eventName);
548
+ }
549
549
  });
550
550
  }
551
551
  }
@@ -562,7 +562,7 @@ const ChatExpress = function(options) {
562
562
 
563
563
  function unmountRoutes(RED, routes, chatServer) {
564
564
  if (routes != null) {
565
- const endpoints = _(routes).keys();
565
+ const endpoints = _.keys(routes);
566
566
  if (!_.isEmpty(endpoints)) {
567
567
  let routesCount = RED.httpNode._router.stack.length;
568
568
  let idx = 0;
@@ -571,7 +571,7 @@ const ChatExpress = function(options) {
571
571
  const route = stack[idx];
572
572
  if (route != null && route.name != null) {
573
573
  const routeName = String(route.name).replace('bound ', '');
574
- if (_.contains(endpoints, routeName)) {
574
+ if (_.includes(endpoints, routeName)) {
575
575
  stack.splice(idx, 1);
576
576
  } else {
577
577
  idx += 1;
@@ -611,7 +611,7 @@ const ChatExpress = function(options) {
611
611
  console.log(lcd.timestamp() + '');
612
612
  // eslint-disable-next-line no-console
613
613
  console.log(lcd.timestamp() + grey('------ WebHooks for ' + options.transport.toUpperCase() + '----------------'));
614
- _(routes).map((middleware, route) => {
614
+ _.each(routes, (middleware, route) => {
615
615
  const host = 'http://localhost' + (uiPort != '80' ? ':' + uiPort : '');
616
616
  const callback = generateCallback(route, chatServer);
617
617
  // make description
@@ -687,8 +687,8 @@ const ChatExpress = function(options) {
687
687
  if (type == null || typeof type !== 'string') {
688
688
  throw 'Missing type in .registerMessageType()';
689
689
  }
690
- name = name != null ? name : _s.capitalize(type);
691
- let typeDescriptor = _(_messageTypes).findWhere({ type: type });
690
+ name = name != null ? name : _.upperFirst(type);
691
+ let typeDescriptor = _.find(_messageTypes, { type: type });
692
692
  if (typeDescriptor == null) {
693
693
  typeDescriptor = { type: type };
694
694
  _messageTypes.push(typeDescriptor);
@@ -715,7 +715,7 @@ const ChatExpress = function(options) {
715
715
  if (name == null || typeof name !== 'string') {
716
716
  throw 'Missing name in .registerEvent()';
717
717
  }
718
- var eventDescriptor = _(_events).findWhere({ name: name });
718
+ var eventDescriptor = _.find(_events, { name: name });
719
719
  if (eventDescriptor == null) {
720
720
  eventDescriptor = { name: name };
721
721
  _events.push(eventDescriptor);
@@ -787,15 +787,48 @@ const ChatExpress = function(options) {
787
787
  console.log(prettyjson.render(obj));
788
788
  };
789
789
  this.request = function(options = {}) {
790
- return new Promise(function(resolve, reject) {
791
- request(options, function(error, response, body) {
792
- if (error) {
793
- reject(`Error calling URL ${options.url}`);
794
- } else {
795
- resolve(body);
796
- }
790
+ var url = options.url || options.uri;
791
+ // Translate "request"-style options into a "fetch" call
792
+ if (options.qs != null) {
793
+ var qs = new URLSearchParams(options.qs).toString();
794
+ if (qs) {
795
+ url += (url.indexOf('?') === -1 ? '?' : '&') + qs;
796
+ }
797
+ }
798
+ var headers = _.extend({}, options.headers);
799
+ var body;
800
+ if (options.json != null && options.json !== true && options.json !== false) {
801
+ body = JSON.stringify(options.json);
802
+ if (headers['content-type'] == null && headers['Content-Type'] == null) {
803
+ headers['Content-Type'] = 'application/json';
804
+ }
805
+ } else if (options.json === true && options.body != null) {
806
+ body = JSON.stringify(options.body);
807
+ if (headers['content-type'] == null && headers['Content-Type'] == null) {
808
+ headers['Content-Type'] = 'application/json';
809
+ }
810
+ } else if (options.form != null) {
811
+ body = new URLSearchParams(options.form).toString();
812
+ if (headers['content-type'] == null && headers['Content-Type'] == null) {
813
+ headers['Content-Type'] = 'application/x-www-form-urlencoded';
814
+ }
815
+ } else if (options.body != null) {
816
+ body = options.body;
817
+ }
818
+ return fetch(url, {
819
+ method: options.method || 'GET',
820
+ headers: headers,
821
+ body: body
822
+ })
823
+ .then(function(response) {
824
+ // Preserve the previous behaviour ({ encoding: null }) of resolving with a Buffer
825
+ return response.arrayBuffer().then(function(buffer) {
826
+ return Buffer.from(buffer);
827
+ });
828
+ })
829
+ .catch(function() {
830
+ return Promise.reject(`Error calling URL ${url}`);
797
831
  });
798
- });
799
832
  };
800
833
  this.getOptions = function() {
801
834
  return this.options;
@@ -815,7 +848,7 @@ const ChatExpress = function(options) {
815
848
  return outboundMessage(message, this);
816
849
  } else {
817
850
  var task = when(true);
818
- _(message.payload).each(function(payload) {
851
+ _.each(message.payload, function(payload) {
819
852
  task = task.then(function() {
820
853
  return outboundMessage(_.extend({}, message, { payload: payload }), _this);
821
854
  });
@@ -861,8 +894,8 @@ const ChatExpress = function(options) {
861
894
  if (type == null || typeof type !== 'string') {
862
895
  throw 'Missing type in .registerMessageType()';
863
896
  }
864
- name = name != null ? name : _s.capitalize(type);
865
- let typeDescriptor = _(_messageTypes).findWhere({ type: type });
897
+ name = name != null ? name : _.upperFirst(type);
898
+ let typeDescriptor = _.find(_messageTypes, { type: type });
866
899
  if (typeDescriptor == null) {
867
900
  typeDescriptor = { type: type };
868
901
  _messageTypes.push(typeDescriptor);
@@ -889,7 +922,7 @@ const ChatExpress = function(options) {
889
922
  if (name == null || typeof name !== 'string') {
890
923
  throw 'Missing name in .registerEvent()';
891
924
  }
892
- var eventDescriptor = _(_events).findWhere({ name: name });
925
+ var eventDescriptor = _.find(_events, { name: name });
893
926
  if (eventDescriptor == null) {
894
927
  eventDescriptor = { name: name };
895
928
  _events.push(eventDescriptor);
@@ -1086,20 +1119,20 @@ const ChatExpress = function(options) {
1086
1119
  Static methods for ChatExpress
1087
1120
  */
1088
1121
  ChatExpress.getMessageTypes = function() {
1089
- return _(_messageTypes).map(function(item) {
1122
+ return _.map(_messageTypes, function(item) {
1090
1123
  return {
1091
1124
  value: item.type,
1092
1125
  label: item.name,
1093
- platforms: _(item.platforms).keys()
1126
+ platforms: _.keys(item.platforms)
1094
1127
  };
1095
1128
  });
1096
1129
  };
1097
1130
  ChatExpress.getEvents = function() {
1098
- return _(_events).map(function(item) {
1131
+ return _.map(_events, function(item) {
1099
1132
  return {
1100
1133
  value: item.name,
1101
1134
  label: item.description,
1102
- platforms: _(item.platforms).keys()
1135
+ platforms: _.keys(item.platforms)
1103
1136
  };
1104
1137
  });
1105
1138
  };
@@ -1110,19 +1143,18 @@ ChatExpress.getParams = function() {
1110
1143
  function compatibilityTable(items, options) {
1111
1144
  options = _.extend({ column: 'Column' }, options);
1112
1145
  // collect platforms except universal
1113
- var platforms = _(ChatExpress.getPlatforms()).chain()
1114
- .map(function(platform) {
1146
+ var platforms = _.reject(
1147
+ _.map(ChatExpress.getPlatforms(), function(platform) {
1115
1148
  return platform.id;
1116
- })
1117
- .reject(function(id) {
1149
+ }),
1150
+ function(id) {
1118
1151
  return id === 'universal';
1119
- })
1120
- .sort()
1121
- .value();
1152
+ }
1153
+ ).sort();
1122
1154
  // build header
1123
1155
  var head = [options.column];
1124
- _(platforms).each(function(name) {
1125
- head.push(_s.capitalize(name));
1156
+ _.each(platforms, function(name) {
1157
+ head.push(_.upperFirst(name));
1126
1158
  });
1127
1159
  var colAligns = ['left'];
1128
1160
  _.times(platforms.length, function() {
@@ -1137,21 +1169,19 @@ function compatibilityTable(items, options) {
1137
1169
  }
1138
1170
  });
1139
1171
  // message types columns
1140
- _(items).chain()
1141
- .sortBy(function(type) {
1142
- return type.name;
1143
- })
1144
- .each(function(type) {
1145
- var row = [type.name];
1146
- _(platforms).each(function(platform) {
1147
- if (type.platforms[platform]) {
1148
- row.push('');
1149
- } else {
1150
- row.push('');
1151
- }
1152
- });
1153
- table.push(row);
1172
+ _.each(_.sortBy(items, function(type) {
1173
+ return type.name;
1174
+ }), function(type) {
1175
+ var row = [type.name];
1176
+ _.each(platforms, function(platform) {
1177
+ if (type.platforms[platform]) {
1178
+ row.push('✔');
1179
+ } else {
1180
+ row.push('');
1181
+ }
1154
1182
  });
1183
+ table.push(row);
1184
+ });
1155
1185
  // eslint-disable-next-line no-console
1156
1186
  console.log(table.toString());
1157
1187
 
@@ -1172,21 +1202,21 @@ ChatExpress.showCompatibilityChart = function() {
1172
1202
  * @return {Array}
1173
1203
  */
1174
1204
  ChatExpress.getPlatforms = function() {
1175
- var platforms = _(_platforms).keys();
1205
+ var platforms = _.keys(_platforms);
1176
1206
 
1177
- return _(platforms).chain()
1178
- .map(function(platform) {
1207
+ return _.sortBy(
1208
+ _.map(platforms, function(platform) {
1179
1209
  return {
1180
1210
  id: _platforms[platform].id,
1181
1211
  name: _platforms[platform].name,
1182
1212
  universal: _platforms[platform].universal,
1183
1213
  color: _platforms[platform].color
1184
1214
  };
1185
- })
1186
- .sortBy(function(platform) {
1215
+ }),
1216
+ function(platform) {
1187
1217
  return platform.name != null ? platform.name : platform.id;
1188
- })
1189
- .value();
1218
+ }
1219
+ );
1190
1220
  };
1191
1221
 
1192
1222
  /**
@@ -1199,9 +1229,9 @@ ChatExpress.getPlatforms = function() {
1199
1229
  ChatExpress.isSupported = function(platform, type) {
1200
1230
  if (type == null) {
1201
1231
  const platforms = ChatExpress.getPlatforms();
1202
- return _(platforms).findWhere({ id: platform }) != null;
1232
+ return _.find(platforms, { id: platform }) != null;
1203
1233
  } else {
1204
- const messageType = _(_messageTypes).findWhere({ type: type });
1234
+ const messageType = _.find(_messageTypes, { type: type });
1205
1235
  return messageType != null && messageType.platforms[platform];
1206
1236
  }
1207
1237
  };
@@ -1219,7 +1249,7 @@ ChatExpress.isSupported = function(platform, type) {
1219
1249
  * @return {String} Null if no errors
1220
1250
  */
1221
1251
  ChatExpress.isValidFile = function(platform, type, file) {
1222
- const messageType = _(_messageTypes).findWhere({ type: type });
1252
+ const messageType = _.find(_messageTypes, { type: type });
1223
1253
  if (messageType != null) {
1224
1254
  const validator = messageType.validators[platform];
1225
1255
  if (validator != null) {
package/helpers/lcd.js CHANGED
@@ -1,7 +1,14 @@
1
1
  var clc = require('cli-color');
2
- var _ = require('underscore');
2
+ var _ = require('lodash');
3
3
  var prettyjson = require('prettyjson');
4
- var moment = require('moment');
4
+
5
+ var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
6
+ // Format a date as 'DD MMM HH:mm:ss' (e.g. '16 Jun 14:30:45')
7
+ function formatTimestamp(date) {
8
+ var pad = function(n) { return n < 10 ? '0' + n : '' + n; };
9
+ return pad(date.getDate()) + ' ' + MONTHS[date.getMonth()] + ' '
10
+ + pad(date.getHours()) + ':' + pad(date.getMinutes()) + ':' + pad(date.getSeconds());
11
+ }
5
12
 
6
13
  var warn = clc.yellow;
7
14
  var grey = clc.blackBright;
@@ -22,7 +29,7 @@ var LCD = {
22
29
  red: red,
23
30
 
24
31
  timestamp() {
25
- return LCD.white(moment().format('DD MMM HH:mm:ss') + ' - [info] ');
32
+ return LCD.white(formatTimestamp(new Date()) + ' - [info] ');
26
33
  },
27
34
 
28
35
  dump: function(e, title) {
@@ -54,7 +61,7 @@ var LCD = {
54
61
  _(payload).each(function(value, key) {
55
62
  if (value instanceof Buffer) {
56
63
  payload[key] = '<Buffer>';
57
- } else if (value instanceof moment) {
64
+ } else if (value instanceof Date) {
58
65
  payload[key] = value.toString();
59
66
  }
60
67
  });
@@ -1,9 +1,9 @@
1
- var _ = require('underscore');
1
+ var _ = require('lodash');
2
2
 
3
3
  var FileQueue = function() {
4
4
  var tasks = [];
5
5
  function removeTask(promise) {
6
- tasks = _(tasks).reject(function(task) {
6
+ tasks = _.reject(tasks, function(task) {
7
7
  return task === promise;
8
8
  });
9
9
  }
package/helpers/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- const _ = require('underscore');
1
+ const _ = require('lodash');
2
2
 
3
3
  module.exports = {
4
4
 
package/lib/lcd.js CHANGED
@@ -1,7 +1,14 @@
1
1
  var clc = require('cli-color');
2
- var _ = require('underscore');
2
+ var _ = require('lodash');
3
3
  var prettyjson = require('prettyjson');
4
- var moment = require('moment');
4
+
5
+ var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
6
+ // Format a date as 'DD MMM HH:mm:ss' (e.g. '16 Jun 14:30:45')
7
+ function formatTimestamp(date) {
8
+ var pad = function(n) { return n < 10 ? '0' + n : '' + n; };
9
+ return pad(date.getDate()) + ' ' + MONTHS[date.getMonth()] + ' '
10
+ + pad(date.getHours()) + ':' + pad(date.getMinutes()) + ':' + pad(date.getSeconds());
11
+ }
5
12
 
6
13
  var warn = clc.yellow;
7
14
  var grey = clc.blackBright;
@@ -22,7 +29,7 @@ var LCD = {
22
29
  red: red,
23
30
 
24
31
  timestamp() {
25
- return LCD.white(moment().format('DD MMM HH:mm:ss') + ' - [info] ');
32
+ return LCD.white(formatTimestamp(new Date()) + ' - [info] ');
26
33
  },
27
34
 
28
35
  dump: function(e, title) {
@@ -57,7 +64,7 @@ var LCD = {
57
64
  _(payload).each(function(value, key) {
58
65
  if (value instanceof Buffer) {
59
66
  payload[key] = '<Buffer>';
60
- } else if (value instanceof moment) {
67
+ } else if (value instanceof Date) {
61
68
  payload[key] = value.toString();
62
69
  }
63
70
  });
package/lib/red-stub.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable */
2
- var _ = require('underscore');
2
+ var _ = require('lodash');
3
3
  var ChatContextFactory = require('../chat-context-factory')({});
4
4
  var ChatContextProvider = ChatContextFactory.getProvider('memory', {});
5
5
 
@@ -38,7 +38,7 @@ module.exports = function() {
38
38
 
39
39
  environment: {
40
40
  chat: function(chatId, obj) {
41
- _(obj).map(function(value, key) {
41
+ _.each(obj, function(value, key) {
42
42
  _chatContext.set(key, value);
43
43
  });
44
44
  }
package/lib/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- const _ = require('underscore');
1
+ const _ = require('lodash');
2
2
 
3
3
  module.exports = {
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chat-platform",
3
- "version": "2.1.4",
3
+ "version": "3.0.0",
4
4
  "description": "Universal Chat Platform",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -10,16 +10,16 @@
10
10
  },
11
11
  "author": "",
12
12
  "license": "ISC",
13
+ "engines": {
14
+ "node": ">=18"
15
+ },
13
16
  "dependencies": {
14
17
  "cli-color": "^1.4.0",
15
18
  "cli-table": "^0.3.1",
16
- "moment": "^2.24.0",
19
+ "lodash": "^4.18.1",
17
20
  "prettyjson": "^1.2.1",
18
- "request": "^2.88.0",
19
- "sequelize": "^5.21.6",
20
- "sqlite3": "^5.0.0",
21
- "underscore": "^1.9.1",
22
- "underscore.string": "^3.3.5"
21
+ "sequelize": "^6.37.8",
22
+ "sqlite3": "^5.1.7"
23
23
  },
24
24
  "devDependencies": {
25
25
  "chai": "^4.1.1",
@@ -1,4 +1,4 @@
1
- const _ = require('underscore');
1
+ const _ = require('lodash');
2
2
 
3
3
  const isEmpty = value => value == null || value === '';
4
4
 
@@ -1,6 +1,5 @@
1
- const _ = require('underscore');
1
+ const _ = require('lodash');
2
2
  const fs = require('fs');
3
- const moment = require('moment');
4
3
  const crypto = require('crypto');
5
4
 
6
5
  const lcd = require('../helpers/lcd');
@@ -20,7 +19,7 @@ const parse = content => {
20
19
  // go through every key/value to search for a date-like string
21
20
  _(obj).each(function(value, key) {
22
21
  if (_.isString(value) && value.match(date)) {
23
- obj[key] = moment(value);
22
+ obj[key] = new Date(value);
24
23
  }
25
24
  });
26
25
 
@@ -241,7 +240,7 @@ _.extend(FileStore.prototype, {
241
240
  // go through every key/value to search for a date-like string
242
241
  _(obj).each((value, key) => {
243
242
  if (_.isString(value) && value.match(date)) {
244
- obj[key] = moment(value);
243
+ obj[key] = new Date(value);
245
244
  }
246
245
  });
247
246
  } catch(e) {
@@ -1,4 +1,4 @@
1
- const _ = require('underscore');
1
+ const _ = require('lodash');
2
2
 
3
3
  const _storeUserIds = {};
4
4
  const Sequelize = require('sequelize');
package/universal.js CHANGED
@@ -1,8 +1,7 @@
1
- const moment = require('moment');
2
1
  const ChatExpress = require('./chat-platform');
3
2
  const utils = require('./lib/utils');
4
3
  const when = utils.when;
5
- const _ = require('underscore');
4
+ const _ = require('lodash');
6
5
 
7
6
  const Universal = new ChatExpress({
8
7
  transport: 'universal',
@@ -14,7 +13,7 @@ const Universal = new ChatExpress({
14
13
  return payload.userId;
15
14
  },
16
15
  tsKey() {
17
- return moment();
16
+ return new Date();
18
17
  },
19
18
  language() {
20
19
  return null;