restchi
v0.7.0
Published
Sane, declarative, promisified REST calls
Downloads
16
Readme
#restchi
#STATUS Not ready for use
Use Case: Sane REST calls. Callable functions based on HTTP verbs instead of absurdly vague method names.
##API Reference
Constructor:
- restchi(rootUrl)
Callable Methods:
- GET (endpoint, options)
- POST (endpoint, data, options)
- PUT (endpoint, data, options)
- DELETE (endpoint, data, options)
##Getting Started
Module Install:
npm i restchi -S
Module Import:
import r from 'restchi';
Object Instantiation:
let rootUri = 'https://www.api.com/v1'; let request = new restchi(rootUri);
REST Method Calls:
let call = request.post('/rest/resource');
##Philosophy
Usage Idioms: Each invoked restchi object correlates to a single root URI. This allows for multiple request calls on that single URI. (e.g. foo.com) by merely changing the endpoint (e.g. /bar [ === foo.com/bar])
###Idiom:
You have the option to pass either a root URI (e.g. foo.com
) or a full URI (e.g. foo.com/bar
). However, you cannot simply call GET/POST/PUT/DELETE without first specifying the root URI.
####Goal:
- Separate callable methods and promise handling logic for sake of readability & ease of use
- Separate root URI's and endpoints for (a) sanity & (b) scoped object reusability [note: getter/setter helper methods exist to bypass this if you are a one object kind of guy/gal]