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.14.1 to 1.14.2

2

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

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

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

if (err) {
return reject(err);
return callback ? callback(err) : reject(err);
}

@@ -403,4 +403,5 @@

var message = resolveAPIErrorArg(errorFormatter.message, data, [data, err.message]);
var error = new errorConstructor(name, message, status, reqinfo, err);
return reject(new errorConstructor(name, message, status, reqinfo, err));
return callback ? callback(error) : reject(error);
}

@@ -422,3 +423,4 @@

resolve(res.body, res.header);
if (callback) callback(null, res.body, res.headers);
else resolve(res.body, res.header);
});

@@ -429,6 +431,2 @@ }

if (!callback) return promise;
promise
.then(callback.bind(null, null))
.catch(callback);
};

@@ -435,0 +433,0 @@

@@ -143,5 +143,9 @@ var extend = require('util')._extend;

this.data = { name: 'Test' };
this.headers = {
'x-header-test': 'OK',
'x-random-header': Math.random().toFixed(5),
};
this.successReq = nock(domain)
.get(endpoint + '/OK')
.reply(200, this.data);
.reply(200, this.data, this.headers);
this.errorReq = nock(domain)

@@ -226,3 +230,20 @@ .get(endpoint + '/FAIL')

});
}
},
'should pass the headers to the callback':
function (done) {
var expectedHeaders = this.headers;
this.client.get({ id: 'OK' }, function(err, body, headers) {
expect(headers).to.exist;
for (var key in expectedHeaders) {
if (expectedHeaders.hasOwnProperty(key)) {
expect(headers).to.have.property(key);
expect(headers[key]).to.equal(expectedHeaders[key]);
}
}
done();
})
},
},

@@ -295,3 +316,3 @@

nock.cleanAll();
this.nock = nock(domain).post(endpoint).replyWithError();
this.nock = nock(domain).post(endpoint).reply(500);

@@ -747,2 +768,3 @@ this.client.post({}, this.resource, function (err) {

expect(request.Request.prototype.proxy.calledWithMatch(proxy)).to.be.true;
request.Request.prototype.proxy.restore();
done();

@@ -765,2 +787,3 @@ });

expect(nockRequest.isDone()).to.be.true;
request.Request.prototype.agent.restore();
done();

@@ -767,0 +790,0 @@ });

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