Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rest-facade

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rest-facade - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

5

package.json
{
"name": "rest-facade",
"version": "1.6.0",
"version": "1.7.0",
"description": "Simple abstraction for consuming REST API endpoints",

@@ -41,5 +41,6 @@ "main": "src/index.js",

"change-case": "^2.3.0",
"deepmerge": "^1.5.1",
"superagent": "^3.5.2",
"deepmerge": "^1.5.1"
"superagent-proxy": "^1.0.2"
}
}

19

README.md

@@ -149,3 +149,3 @@ # rest-facade [![Build Status](https://travis-ci.org/ngonzalvez/rest-facade.svg?branch=master)](https://travis-ci.org/ngonzalvez/rest-facade)

> N.B. any properties in a given `options` object whose values are Functions will be ignored with regard to generating the query string.
> N.B. any properties in a given `options` object whose values are Functions will be ignored with regard to generating the query string.

@@ -203,5 +203,5 @@ ~~~js

~~~js
client.create({ firstName: 'John', lastName: 'Doe' });
client.create({ firstName: 'John', lastName: 'Doe' });
// The server will receive
// The server will receive
// { first_name: 'John', last_name: 'Doe' }

@@ -213,3 +213,3 @@ ~~~

### Per-Request Customization
Sometimes you need to do some customization to each individual request that is sent to the consumed API,
Sometimes you need to do some customization to each individual request that is sent to the consumed API,
a likely candidate is for adding request-specific headers.

@@ -219,3 +219,3 @@

- defining a function in global options under `options.request.customizer`
- defining a function in global options under `options.request.customizer`
- passing in a options object to a method call that contains a "special" `_requestCustomizer` property (which should be a function as well!)

@@ -227,2 +227,11 @@

### Proxy support
If a proxy URI is provided, **all** requests will be sent through that proxy.
```js
// Rest client that sends all requests through a proxy server.
var client = new rest.Client(url, {
proxy: 'https://myproxy.com:1234'
});
```

@@ -6,2 +6,3 @@ var extend = require('util')._extend;

var request = require('superagent');

@@ -15,2 +16,5 @@ var Promise = require('bluebird');

// Add proxy support to the request library.
require('superagent-proxy')(request);
/**

@@ -242,2 +246,3 @@ * @class

var reqCustomizer = this.options.request.customizer;
var proxy = this.options.proxy;
var newKey = null;

@@ -281,4 +286,10 @@ var value = null;

// Set methods and attach the body of the request (if this is a POST request).
var req = request[method](options.url).send(options.data);
var req = request[method](options.url);
if (proxy) {
req = req.proxy(proxy);
}
req = req.send(options.data);
// Add request headers.

@@ -285,0 +296,0 @@ for (var header in headers) {

@@ -20,4 +20,6 @@ module.exports = {

}
}
},
proxy: null
};

@@ -12,2 +12,4 @@ var extend = require('util')._extend;

var request = require('superagent');
var domain = 'http://domain.com';

@@ -638,4 +640,20 @@ var endpoint = '/endpoint';

},
'should use the proxy defined in the global settings':
function (done) {
var proxy = 'https://proxyserver.com';
var client = this.client = new Client(domain + endpoint, { proxy: proxy });
var req = nock(domain).get(endpoint).reply(200);
var spy = sinon.spy(request.Request.prototype, 'proxy');
client
.getAll()
.then(function(data) {
expect(request.Request.prototype.proxy.calledWithMatch(proxy)).to.be.true;
done();
});
},
}
}
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc