Skip to content

Instantly share code, notes, and snippets.

@yeffrimic
Created July 25, 2017 20:57
Show Gist options
  • Save yeffrimic/3e22b413e60ba13783f302f71cfbf1e3 to your computer and use it in GitHub Desktop.
Save yeffrimic/3e22b413e60ba13783f302f71cfbf1e3 to your computer and use it in GitHub Desktop.
context.msg = context.msg || {};
switch (msg.topic){
case 'message':
context.msg.payload = msg.payload;
break;
case 'topic':
context.msg.topic = msg.payload;
break;
case 'submit':
if(context.msg.topic){
return context.msg;
}else{
context.msg.topic="#"; // set default topic
return context.msg;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment