easy-api
Super easy promise-based api declaration.

Install
npm install --save easy-api
Usage
Declaring route and using handlers is super easy
var easyApi = require('easy-api')
easyApi()
.get(
'/some/object/:someParameter/:someOtherParameter',
function(someParameter, someOtherParameter) {
return doAnythingNotPromisified(someParameter, someOtherParameter);
// or...
return doAnythingPromisified(someParameter, someOtherParameter);
}
)
.post(
'/some/object',
function(label, content, catName) {
return createObjectHoweverYouWant(label, content, catName);
}
)
.start(4567)
No need to deal with request and response objects, just declare named parameters in the route and you will get them as parameter in the handler.
Get
easyApi().get(
'/object/:foo/sub-object/:bar',
function(bar, foo) {
// ...
}
)
Handler function can return either a promise or a value.
Post
easyApi().post(
'/object/:foo/sub-object',
function(barName, foo) {
// ...
}
)
To get the correct value for barName parameter, it must be included in the payload in the call.
Tests
npm test
