chat-platform 2.0.0 → 2.0.1
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/chat-platform.js +13 -13
- package/helpers/lcd.js +4 -0
- package/package.json +1 -1
package/chat-platform.js
CHANGED
|
@@ -73,15 +73,15 @@ const ChatExpress = function(options) {
|
|
|
73
73
|
// configuration warnings
|
|
74
74
|
if (_.isEmpty(this.options.chatIdKey) && !_.isFunction(this.options.chatIdKey)) {
|
|
75
75
|
// eslint-disable-next-line no-console
|
|
76
|
-
console.log(yellow('WARNING: chatIdKey option is empty'));
|
|
76
|
+
console.log(lcd.timestamp() + yellow('WARNING: chatIdKey option is empty'));
|
|
77
77
|
}
|
|
78
78
|
if (_.isEmpty(this.options.userIdKey) && !_.isFunction(this.options.userIdKey)) {
|
|
79
79
|
// eslint-disable-next-line no-console
|
|
80
|
-
console.log(yellow('WARNING: userIdKey option is empty'));
|
|
80
|
+
console.log(lcd.timestamp() + yellow('WARNING: userIdKey option is empty'));
|
|
81
81
|
}
|
|
82
82
|
if (_.isEmpty(this.options.transport)) {
|
|
83
83
|
// eslint-disable-next-line no-console
|
|
84
|
-
console.log(yellow('WARNING: transport option is empty'));
|
|
84
|
+
console.log(lcd.timestamp() + yellow('WARNING: transport option is empty'));
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
function evaluateParam(payload, newKey, optionKey, chatServer) {
|
|
@@ -154,11 +154,11 @@ const ChatExpress = function(options) {
|
|
|
154
154
|
// check if message is null, perhaps someone forgot to resolve a promise
|
|
155
155
|
if (message == null) {
|
|
156
156
|
// eslint-disable-next-line no-console
|
|
157
|
-
console.log(yellow('WARNING: a middleware is returning an empty message'));
|
|
157
|
+
console.log(lcd.timestamp() + yellow('WARNING: a middleware is returning an empty message'));
|
|
158
158
|
}
|
|
159
159
|
if (message.payload == null) {
|
|
160
160
|
// eslint-disable-next-line no-console
|
|
161
|
-
console.log(yellow('WARNING: a middleware is returning an empty payload in message'));
|
|
161
|
+
console.log(lcd.timestamp() + yellow('WARNING: a middleware is returning an empty payload in message'));
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
|
|
@@ -333,7 +333,7 @@ const ChatExpress = function(options) {
|
|
|
333
333
|
.then(() => when(message));
|
|
334
334
|
} else {
|
|
335
335
|
// eslint-disable-next-line no-console
|
|
336
|
-
console.log(yellow('WARNING: context provider was not specified'));
|
|
336
|
+
console.log(lcd.timestamp() + yellow('WARNING: context provider was not specified'));
|
|
337
337
|
}
|
|
338
338
|
// run general middleware
|
|
339
339
|
_(_this.uses.concat(chatServer.getUseMiddleWares())).each(function(filter) {
|
|
@@ -604,9 +604,9 @@ const ChatExpress = function(options) {
|
|
|
604
604
|
const uiPort = RED.settings.get('uiPort');
|
|
605
605
|
const options = chatServer.getOptions();
|
|
606
606
|
// eslint-disable-next-line no-console
|
|
607
|
-
console.log('');
|
|
607
|
+
console.log(lcd.timestamp() + '');
|
|
608
608
|
// eslint-disable-next-line no-console
|
|
609
|
-
console.log(grey('------ WebHooks for ' + options.transport.toUpperCase() + '----------------'));
|
|
609
|
+
console.log(lcd.timestamp() + grey('------ WebHooks for ' + options.transport.toUpperCase() + '----------------'));
|
|
610
610
|
_(routes).map((middleware, route) => {
|
|
611
611
|
const host = 'http://localhost' + (uiPort != '80' ? ':' + uiPort : '');
|
|
612
612
|
const callback = generateCallback(route, chatServer);
|
|
@@ -618,14 +618,14 @@ const ChatExpress = function(options) {
|
|
|
618
618
|
description = routesDescription[route].call(chatServer);
|
|
619
619
|
}
|
|
620
620
|
// eslint-disable-next-line no-console
|
|
621
|
-
console.log(green(host + callback) + (description != null ? grey(' - ') + white(description) : ''));
|
|
621
|
+
console.log(lcd.timestamp() + green(host + callback) + (description != null ? grey(' - ') + white(description) : ''));
|
|
622
622
|
// attach to Express instance
|
|
623
623
|
const escaped = String(`^${callback}$`).replace(RegExp('/', 'g'), '\\/');
|
|
624
624
|
RED.httpNode.use(new RegExp(escaped), middleware.bind(chatServer));
|
|
625
625
|
return null;
|
|
626
626
|
});
|
|
627
627
|
// eslint-disable-next-line no-console
|
|
628
|
-
console.log('');
|
|
628
|
+
console.log(lcd.timestamp() + '');
|
|
629
629
|
}
|
|
630
630
|
return when(true);
|
|
631
631
|
}
|
|
@@ -976,7 +976,7 @@ const ChatExpress = function(options) {
|
|
|
976
976
|
.then(function() {
|
|
977
977
|
if (_this.isDebug()) {
|
|
978
978
|
// eslint-disable-next-line no-console
|
|
979
|
-
console.log(green('Chat server started, transport: ') + white(options.transport));
|
|
979
|
+
console.log(green(lcd.timestamp() + 'Chat server started, transport: ') + white(options.transport));
|
|
980
980
|
}
|
|
981
981
|
// listen to inbound event
|
|
982
982
|
var connector = options.connector;
|
|
@@ -1025,7 +1025,7 @@ const ChatExpress = function(options) {
|
|
|
1025
1025
|
} catch(e) {
|
|
1026
1026
|
// todo better error displaying
|
|
1027
1027
|
// eslint-disable-next-line no-console
|
|
1028
|
-
console.log('Error in resolver chatId<->userId', e);
|
|
1028
|
+
console.log(lcd.timestamp() + 'Error in resolver chatId<->userId', e);
|
|
1029
1029
|
throw new Error('Error in resolver chatId<->userId', e);
|
|
1030
1030
|
}
|
|
1031
1031
|
};
|
|
@@ -1041,7 +1041,7 @@ const ChatExpress = function(options) {
|
|
|
1041
1041
|
} catch(e) {
|
|
1042
1042
|
// todo better error displaying
|
|
1043
1043
|
// eslint-disable-next-line no-console
|
|
1044
|
-
console.log('Error in resolver chatId<->preferred transport', e);
|
|
1044
|
+
console.log(lcd.timestamp() + 'Error in resolver chatId<->preferred transport', e);
|
|
1045
1045
|
throw new Error('Error in resolver chatId<->preferred transport', e);
|
|
1046
1046
|
}
|
|
1047
1047
|
};
|
package/helpers/lcd.js
CHANGED
|
@@ -21,6 +21,10 @@ var LCD = {
|
|
|
21
21
|
orange: orange,
|
|
22
22
|
red: red,
|
|
23
23
|
|
|
24
|
+
timestamp() {
|
|
25
|
+
return LCD.white(moment().format('DD MMM HH:mm:ss') + ' - [info] ');
|
|
26
|
+
},
|
|
27
|
+
|
|
24
28
|
dump: function(e, title) {
|
|
25
29
|
this.title(!_.isEmpty(title) ? title : 'Error');
|
|
26
30
|
if (e instanceof Error) {
|