1.10.11 • Published 7 years ago

global-rest v1.10.11

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

global-rest

The is a wreckless and contraversial REST library I wrote that caters to the laziest of developers that will go to all costs to not write the same code over and over albeit just changing the URL string a tad, who are also sicking of writing the exact same response success and error callbacks for every REST call that takes place.

Also it should be noted that this library was not created for the purpose of interacting with third-party REST APIs like Facebook API, Twitter, etc as they design their URLs using there own convention. It should be used to interact with the backend of your own application where you will have control of how your endpoints will look.

Require the package only once in the entire app and create a global baseUrl and you should be good to go:

global.baseUrl = "http://some-rest-service.com";
require('global-rest');

##Installation:

npm install global-rest

##Usage: This library is built based on the assumption you are doing your api endpoints in a basic RESTful way i.e /resource, /resource/:id for all the HTTP verbs. Also it is dependent on how you name your functions, as long as the last word in the name of your function is the resource name you will be fine, something you probably already do

WARNING: WILL NOT WORK IN STRICT MODE....yet

//GET: "http://some-rest-service.com/users" //pass in a optional 'id' param to make a call for one user

function getUsers(){
	$get() //return a thenable promise
}

//PUT: "http://some-rest-service.com/profile/:id"

function updateUserProfile(id,userData){
	$put(id,userData); //return a thenable promise
}

//DELETE: "http://some-rest-service.com/users/:id"

function deleteUsers(id){
	$delete(id); //return a thenable promise
}

//POST: "http://some-rest-service.com/users/:id"

function createUsers(id,user){
	$post(id,user); //return a thenable promise
}
1.10.11

7 years ago

1.10.10

7 years ago

1.10.9

7 years ago

1.10.8

7 years ago

1.10.7

7 years ago

1.10.6

7 years ago

1.10.5

7 years ago

1.10.4

7 years ago

1.10.3

7 years ago

1.10.1

7 years ago

1.10.0

7 years ago

1.9.0

7 years ago

1.8.0

7 years ago

1.7.0

7 years ago

1.6.0

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago