1.0.5 • Published 10 years ago

restful-promise v1.0.5

Weekly downloads
5
License
MIT
Repository
github
Last release
10 years ago

restful-promise NPM version

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.

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago