apis-resource
Add resource helper for apis lib
Resource
res.resource = 'user',
res.get = function(auth, data, cb) {};
res.create = function(auth, data, cb) {};
request or response
request = {
get: function() {
return {email: email}
},
create: function() {
return {
email: email,
password: str,
name: opt(str),
}
}
}
Usage
add(
contract,
{
handler
authFunc
},
{
base,
api,
request,
response
}
)
Example
var addResource = require('apis-resource').add;
...
Contract.prototype.unitInit = function (units) {
var auth = units.require('auth').handler;
var userApi = units.require('user.api');
var userRequest = units.require('user.request');
add(this, {handler: auth}, {
base: '/api/1',
api: userApi,
request: userRequest
});
};