restnest

v0.1.4-beta
[![NPM version](https://img.shields.io/npm/v/restnest.svg?style=flat-square)](https://www.npmjs.com/package/restnest) [![Travis CI](https://img.shields.io/travis/plouc/restnest.svg?style=flat-square)](https://travis-ci.org/plouc/restnest)

RESTNEST

NPM version Travis CI

RestNest is a small client targeting json REST APIs consumption. Be warned that it's a project to play with es6 features, so use it at your own risk :)

Motivation

Provide a simple way to describe your APIs and consume it.

Example using the github api.

var r = require('restnest');
var a = require('restnest/superagent_adapter');

// create the client, declare resources
var api = r.def({
    path: 'https://api.github.com',
    headers: { Accept: 'application/vnd.github.v3+json' },
    resources: {
        users: {
            path: '/users',
            resources: {
                list: {},
                user:  {
                    path: '/:username',
                    resources: {
                        repos:     { path: '/repos'     },
                        gists:     { path: '/gists'     },
                        orgs:      { path: '/orgs'      },
                        followers: { path: '/followers' }
                    }
                }
            }
        }
    }
});

// consume
r.call(r.with(api, 'users.user.repos'), a, {
    username: 'plouc'
})
    .then(function (res) {
    })
    .catch(function (err) {
    })
;
npm i restnest

Metadata

  • ISC
  • Whatever
  • RaphaĆ«l Benitte
  • released 2/25/2015

Downloads

Maintainers