Socket
Socket
Sign inDemoInstall

boom

Package Overview
Dependencies
1
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.1.0

31

lib/index.js

@@ -73,2 +73,33 @@ // Load modules

// Return custom keys added to the error root or response.payload
internals.Boom.prototype.decorations = function () {
var decoration = {};
var rootKeys = Object.keys(this);
for (var i = 0, il = rootKeys.length; i < il; ++i) {
var key = rootKeys[i];
if (typeof this[key] !== 'function' &&
key[0] !== '_' &&
['isBoom', 'response', 'message'].indexOf(key) === -1) {
decoration[key] = this[key];
}
}
var responseKeys = Object.keys(this.response.payload);
for (i = 0, il = responseKeys.length; i < il; ++i) {
var key = responseKeys[i];
if (['code', 'error', 'message'].indexOf(key) === -1) {
decoration.response = decoration.response || {};
decoration.response[key] = this.response.payload[key];
}
}
return decoration;
};
// 4xx Client Errors

@@ -75,0 +106,0 @@

2

package.json
{
"name": "boom",
"description": "HTTP-friendly error objects",
"version": "1.0.2",
"version": "1.1.0",
"repository": "git://github.com/spumko/boom",

@@ -6,0 +6,0 @@ "main": "index",

@@ -42,2 +42,20 @@ // Load modules

describe('#decorations', function () {
it('returns custom members', function (done) {
var error = Boom.badRequest('Custom');
error.a1 = 'Have an A1 day';
error.response.payload.walt = 'heisenberg';
expect(error.decorations()).to.deep.equal({
a1: 'Have an A1 day',
response: {
walt: 'heisenberg'
}
});
done();
});
});
describe('#isBoom', function () {

@@ -44,0 +62,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc