0.2.0 • Published 9 years ago
hr.backend v0.2.0
hr.backend
Backend with fallback
Installation
$ npm install hr.backend
Documentation
var Backend = require("hr.backend");
var myApi = new Backend({
});
// Handle api method
myApi.defaultMethod({
execute: function(args, options, method) {
return doSomeHttpStuff(method, args);
}
});
// Ask to cache the method "GET:posts"
myApi.addCachedMethod("GET:posts");
// Execute an api call
myApi.execute("GET:posts")
.then(function(results) {
// Results will come from the http server or the cache if offline
});