Tonic, a JS Bin With Npm Attached at the Hip

- - | Comments

Tonic is a new service/tool for web developers that I’ve been playing with for a couple of days. It’s very similar to an IPython notebook, but completely through a web interface. It’s very interactive, and allows you to fluently write, test, and play around with Node.js code. You can test things out very quickly, just like JSFiddle, JSBin, CodePen or Plunker, but it is backed by npm which makes it much nicer.

This is their marketing copy. They say that Tonic removes friction. I was very surprised by how true that was.

NPM is first class

Any require statement is automatically parsed, and the dependency is added to the implcit package.json file that backs every “Notebook”. You don’t have to fiddle around with the JSON yourself, but rather just add var request = require('request'); and you automagically have the current version of request. There’s also some special additional syntax to use in your requrie statement if you do happen to require specific versions.

Endpoints are first class

The killer feature of this tool though is not the npm integration, but rather its ability to create on the fly APIs. I’ve been looking for something like this from a lot of other tools. I have wished there was a way to create a one liner API and deploy to Heroku as an endpoint by only using the web. Until now, I haven’t had anything like that. Now, not only do I get an API in 2 clicks and 3 lines of code, but it also supports CORS!

Creating a new http endpoint is as easy as clicking on compose in gmail. Clicking on new Notebook, and then writing this code, got me a passthrough to a non CORS, but open endpoint in < 5 minutes.

No more needing to spin up node on my VPS just to CORS enable APIs!

This is basically a two liner (of not boilerplate) to get my own Duolingo profile. In case you don’t know, I’m extremely addicted to Duolingo and many of my side projects are tools to remind me to practice learning languages every day. Tonic is going to make that tool writing so much easier! I don’t need node proxies anymore, I can just build my apps in JS Bin, calling to this new Tonic-built endpoint and be done in minutes!

I’m really excited about this; I’m sure you can tell. See you in the comments!

Comments