bloc referral

If you are interested in learning to code with a mentor, try bloc and get $100 off.

Monday, January 12, 2015

node Battle: The integration of slack and typeform

This weekend was planned for the exploration of new territory. I have had a new idea for my first Ember app for quite some time and was ready begin from `ember new`.

I also recently joined up with a group to startup a new idea (more details in a future post) for a community. My first task for the group was to integrate slack into the app, sounds easy enough since there is a popular blog post on how someone did it in php. I am not exaggerating when I say I have had no php experience, but expected to learn it quickly enough to follow a blog post, well the blog post was not as clear as I would of thought it to be. I expected more steps and ideas on how to run a php script and the s/o questions and google searches made too many assumptions on my skill level in php.

After spending about an hour in php, I decided to search for a different solution and possible come back to php if needed.

Here comes the node

Now what I was doing is farely new and the blog post was only written 2 months ago, either there is not a need for this sort of slack integration or I am on the cutting edge. Regardless, when I tried searching only 3 implementations came up, and one was just a bot reposting the first php article.

Luckily the other choice was node, a version of Javascript I had some experience learning in. I stumble on the cleverly named slack-typeform-inviter, great for seo, and quickly enough of the code to realize it made sense. I forked the project and began inserting the needed API keys for Slack and Typeform.

I then Ran the code and boomed error, `SyntaxError: Unexpected token *`.  Hmmm, why would someone post code with syntax errors?

Actually it is not a syntax error, but actually a new syntax for the release candidate .11. Yep the code was written on an unstable version of node and I was an unstable developer at that point.

Now I wrote my solution in what took about 5 seconds for you to read, but it took about 3 hours of banging my head on the keyboard trying to figure out how to debug this code. I removed the "*'s"  from the deferred calls, which I found out to be to sort of like yields for arguments, but once those were removed I was getting errors on the yields.

I finally removed the yields and got the code fail everywhere there was a "request" or "response" call. This was weird, so I ended up emailing the contributor. In hindsight I recommend opening up an issue on github instead, I got a super quick response letting me know it was the newest unstable node code and a picture of the developer at a KPOP concert in Thailand. I felt bad to bother him but relieved that I could get the code to work.

But only if it was that easy, I did spend about 4 hours figuring out how to install an unstable version of node and debug why it was not working on my computer. Those fours plus probably more as I moved into the next day were spend installing dev tools on my wife's mac to test that the code worked. Luckily all I had to do was copy and paste my .vimrc, which is testament to VIM and why you should use it.

I ended up discovering nvm (similar to rvm) to install the "unstable" version of node and  switch back and forth when needed.

There was an incredible amount of troubleshooting this weekend, but it taught a deep understanding of how npm and node_module management works. It also gave a chance to write some production ready node code. Also the code works which is a relief.

Thanks to Chad Scira for being so responsive in email and originally writing the slack-typeform-inviter

*I have submitted a pull request to help anyone else who might want to use the node pack in the future. Which has already been merged!

Now I hope next weekend I can get past ember new.



1 comment: