restjs-api
Advanced tools
Comparing version 0.1.4 to 0.1.5
{ | ||
"name": "restjs-api", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Kidozen's connector to invoke REST services", | ||
@@ -9,6 +9,2 @@ "main": "index.js", | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/kidozen/node-restjs-api.git" | ||
}, | ||
"keywords": [ | ||
@@ -19,4 +15,4 @@ "kidozen", | ||
], | ||
"author": "Silvio Massari", | ||
"license": "BSD", | ||
"author": "Kidozen <development@kidozen.com>", | ||
"license": "MIT", | ||
"dependencies": { | ||
@@ -23,0 +19,0 @@ "winston": "0.6.2", |
@@ -6,81 +6,1 @@ # REST client for Node.js | ||
This module is based on module [Request](http://github.com/mikeal/request.git). | ||
## Installation | ||
Use npm to install the module: | ||
``` | ||
> npm install restjs-api | ||
``` | ||
## Runing tests | ||
Use npm to run the set of tests: | ||
``` | ||
> npm test | ||
``` | ||
## API | ||
Due to the asynchronous nature of Nodejs, this module uses callbacks in requests. All callbacks have 2 arguments: `err` and `data`. | ||
``` | ||
function callback (err, data) { | ||
// err contains an Error class instance, if any | ||
// data contains the resulting data | ||
} | ||
``` | ||
### Constructor | ||
The module exports a class and its constructor requires a configuration object with following property: | ||
* `endpoint`: Required string. URL to the service. | ||
* `headers`: Optional object containing http headers, defaults to {}. | ||
``` | ||
var Rest = require("restjs-api"); | ||
var rest = new Rest({ endpoint: "http://your-service" }); | ||
``` | ||
### Methods | ||
All public methods has the same signature, their have two arguments: `options` and `callback`: | ||
* `options` must be an object instance containig all parameters for the method. | ||
* `callback` must be a function. | ||
#### exec(options, callback) | ||
This method sends an HTTP request to the REST service. | ||
Parameters: | ||
* `options` (object) Required. Specifies headers, body, timeout, etc. The option 'method' is the only one that is required. | ||
* `method`: string. HTTP method. i.e.: GET, POST, DELETE, etc. | ||
* `path`: string. resource. | ||
* `qs`: object containing querystring values to be appended to the uri | ||
* `headers`: http headers, defaults to {} | ||
* `body`: entity body for PATCH, POST and PUT requests. Must be buffer or string. | ||
* `followRedirect`: follow HTTP 3xx responses as redirects. defaults to true | ||
* `followAllRedirects`: follow non-GET HTTP 3xx responses as redirects. defaults to false. | ||
* `maxRedirects`: the maximum number of redirects to follow, defaults to 10. | ||
* `encoding`: Encoding to be used on setEncoding of response data. If set to null, the body is returned as a Buffer. | ||
* `timeout`: Integer containing the number of milliseconds to wait for a request to respond before aborting the request | ||
* `proxy`: An HTTP proxy to be used. Support proxy Auth with Basic Auth by embedding the auth info in the uri. | ||
* `jar`: Set to false if you don't want cookies to be remembered for future use or define your custom cookie jar | ||
* `auth`: A hash containing user, password and sendImmediately. See documentation at https://github.com/mikeal/request#http-authentication | ||
* `oauth`: Options for OAuth HMAC-SHA1 signing, see documentation at https://github.com/mikeal/request#oauth-signing | ||
* `aws`: Object containing aws signing information, should have the properties key and secret as well as bucket unless you're specifying your bucket as part of the path, or you are making a request that doesn't use a bucket. | ||
* `callback`: A required function for callback. | ||
#### get(options, callback) | ||
This method is a shortcut to invoke the method `exec` with the option `method = "GET"` | ||
#### put(options, callback) | ||
This method is a shortcut to invoke the method `exec` with the option `method = "PUT"` | ||
#### post(options, callback) | ||
This method is a shortcut to invoke the method `exec` with the option `method = "POST"` | ||
#### delete(options, callback) | ||
This method is a shortcut to invoke the method `exec` with the option `method = "DELETE"` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
0
0
1
12154
6
1