restful-promise
v1.0.5
Published
Promise-based RESTful API for node applications.
Downloads
4
Maintainers
Readme
restful-promise
Promise-based RESTful API for node applications.
$ npm install restful-promise
Hybrid of rest-interface and simple-promise libraries - basically a RESTful application interface that operates on promises.
Code Samples
Your best resource is the docs for the two parent libraries, but here are some quick code samples to help you get started.
Define your API
API definition stays exactly the same as it was in rest-interface...
var api = require('restful-promise');
module.exports = api({
get: function (done, all, your, args) {
// "done" signals that your async behavior
// has completed.
done(some, values);
},
post: ..,
put: ..,
delete: ..
});
Using your API
... the difference is that REST actions are now promises!
var mycoolapi = require('mycoolapi');
var out = mycoolapi.put('some', 'args')
.then(function (result) {
// do something with result of promise.
})
.error(function (err) {
// do something if an error occurred.
});
// Value of "out" will be the return value of the put operation.
- See: http://github.com/cobbdb/restful-promise
- License: MIT