Charon is a little API client factory, created to abstract away some of the nitty gritty aspects of interacting with a ReST API over HTTP. At its core, Charon is a means of organizing an API domain into a single client-namespace with a hierarchical set of services and a consistent interface.
But wait, there's more!
Charon is a simple library focused on abstracting RESTful service calls.
Service methods have a familiar
(data, [options,] callback) signature, and
callbacks are called with
(err, data) - that's the only interface your
application code should have to deal with.
Charon is designed to produce stateless clients, and data is passed around as plain old JSON-serializable objects with no getter/setter functions or any other monkey business. Because Charon isn't a framework and isn't tied to any framework, you should be able to integrate it into pretty much any app (or your favorite framework) without too many complications.
// Create a client for our business's REST API.var CandyShop = Charon;// Now let's create a ResourceManager to contain several services which// act on the same resource type.CandyShopLollipop = CandyShop;// We'll declare some basic CRUD services for our ResourceManager// (note, all share the ResourceManager's default URL method)CandyShopLollipop;// Clients can be initialized with dynamic configuration data. This should// only be done once, when your app is starting up (aka "bootstrap" phase).CandyShop;// Service calls accept a ``data`` object param and an ``options`` object// param. ``data`` should generally be limited to stuff that you consider part// of the resource definition, while options should generally be optional.// Following these rough rules of thumb are not required, but will make your// client more consistent.CandyShopLollipop;