forrest

all restful service's api

npm install forrest
10 downloads in the last week
10 downloads in the last month

forrest

work with restful server using oauth2, you can use like:

var restful=forrest({
  protocol:http, //default to https
  port:3000,//default to 80
  host:'restful.server.host', //the host provide the restful service
  authHost:'oauth2.server.host', //the oauth host
  authPath:'/path/to/oauth',
  tokenPath:'/path/to/token',
  redirect:'http://yourhost/to_handle_oauth_code',
  key:'your app key',
  secret:'your secret'
});

the auth path where you can log into:

var auth_path=restful.$authPath;

handle the code and transfer it to access token

restful.$getToken(oauth_code,function(err,ret){
  if(err)return err;
  var token=ret.access_token;
});

add a interface

restful.$add('users','GET','/user/list',{
  /*type,required,[default_value]*/
  userID:['string',true,'default']
});

then simpliy use:

restful.users({userID:123},function(err,ret){
  if(err)return err;
  console.log(ret);
});
npm loves you