1616
1717module . exports = function ( RED ) {
1818 var cfenv = require ( 'cfenv' ) ;
19-
20- var services = cfenv . getAppEnv ( ) . services ,
21- service ;
2219
2320 var username , password ;
2421
@@ -38,6 +35,8 @@ module.exports = function (RED) {
3835 var node = this ;
3936
4037 this . on ( 'input' , function ( msg ) {
38+ var message = '' ;
39+
4140 if ( ! msg . payload ) {
4241 var message = 'Missing property: msg.payload' ;
4342 node . error ( message , msg ) ;
@@ -48,7 +47,7 @@ module.exports = function (RED) {
4847 password = password || this . credentials . password ;
4948
5049 if ( ! username || ! password ) {
51- var message = 'Missing Tone Analyzer service credentials' ;
50+ message = 'Missing Tone Analyzer service credentials' ;
5251 node . error ( message , msg ) ;
5352 return ;
5453 }
@@ -68,18 +67,19 @@ module.exports = function (RED) {
6867
6968 var hasJSONmethod = ( typeof msg . payload . toJSON === 'function' ) ;
7069 var isBuffer = false ;
71- if ( hasJSONmethod == true )
72- {
73- if ( msg . payload . toJSON ( ) . type == 'Buffer' )
74- isBuffer = true ;
70+
71+ if ( hasJSONmethod === true ) {
72+ if ( msg . payload . toJSON ( ) . type === 'Buffer' ) {
73+ isBuffer = true ;
74+ }
7575 }
7676
7777 // Payload (text to be analysed) must be a string (content is either raw string or Buffer)
78- if ( typeof msg . payload == 'string' || isBuffer == true )
78+ if ( typeof msg . payload === 'string' || isBuffer = == true )
7979 {
8080 var options = {
8181 text : msg . payload ,
82- sentences : config . sentences ,
82+ sentences : sentences ,
8383 isHTML : contentType
8484 } ;
8585
@@ -100,7 +100,7 @@ module.exports = function (RED) {
100100 } ) ;
101101 }
102102 else {
103- var message = 'The payload must be either a string or a Buffer' ;
103+ message = 'The payload must be either a string or a Buffer' ;
104104 node . status ( { fill :'red' , shape :'dot' , text :message } ) ;
105105 node . error ( message , msg ) ;
106106 }
0 commit comments