RestWrapper
Simple REST Calls for NODE/Browserify
Version: 0.0.17 I wrote this to be a simple way to communicate to REST Servers using the same syntax in my Node / Browserify applications.
It's a nice starting point for the mysterious WEB API often mentioned in FLUX tutorials.
URI can be parameterized according to http://tools.ietf.org/html/rfc6570
RestWrapper(uri, [paramDefaults], [headers]);
paramDefaults - Populate the uri template variables from payload object by prefixing an '@' in the attributes value headers - pass any default headers as an object, ex {'secretToken':123}
Examples
var Message = 'http://example.com/messages/{messageID}' messageID:'@id';Message; or Message;
var newMessage = text:"Hey, I think you're cool.";Message; var modifiedMessage = id:123 text:"Heeeeeey";//messageID is set from the id in the message objectMessage;
Feel free to tack on your own methods
Message{ ifpayloadid return this; else return this; };