New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hapi-boombox

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-boombox - npm Package Compare versions

Comparing version 8.0.0 to 8.0.2

7

.eslintrc.js

@@ -6,8 +6,9 @@ 'use strict';

node: true,
es6: true
es6: true,
es2020: true
},
parserOptions: {
ecmaVersion: 2018
ecmaVersion: 2020
},
extends: '@hapi/eslint-config-hapi',
extends: 'plugin:@hapi/recommended',
rules: {

@@ -14,0 +15,0 @@ 'no-undef': 2,

@@ -11,19 +11,2 @@ 'use strict';

internals.boom = function boom(error) {
const data = internals.errors[error.message];
if (!data ) {
return error;
}
const customBoom = Boom[data.type]();
const explosion = new Error(data.message);
Boom.boomify(explosion, { statusCode: customBoom.output.statusCode });
explosion.isBoombox = true;
return explosion;
};
exports.plugin = {

@@ -47,2 +30,3 @@ pkg: require('../package.json'),

// We only want to handle Boom errors with statusCode >= 500
if (!request.response.isServer) {

@@ -52,3 +36,16 @@ return h.continue;

return internals.boom(request.response);
const data = internals.errors[request.response.message];
if (!data) {
// If we're not transforming anything just continue the lifecycle
return h.continue;
}
const customBoom = Boom[data.type]();
const explosion = new Error(data.message);
Boom.boomify(explosion, { statusCode: customBoom.output.statusCode });
explosion.isBoombox = true;
return explosion;
});

@@ -55,0 +52,0 @@

{
"name": "hapi-boombox",
"version": "8.0.0",
"version": "8.0.2",
"description": "Boom error wrapper",

@@ -24,11 +24,10 @@ "main": "lib/index.js",

"dependencies": {
"@hapi/boom": "~9.0.0"
"@hapi/boom": "~9.1.0"
},
"devDependencies": {
"@hapi/code": "8.0.1",
"@hapi/eslint-config-hapi": "^13.0.2",
"@hapi/eslint-plugin-hapi": "^4.3.5",
"@hapi/hapi": "^18.4.0",
"@hapi/basic": "5.1.1",
"@hapi/lab": "22.0.3"
"@hapi/basic": "6.0.0",
"@hapi/code": "8.0.2",
"@hapi/eslint-plugin": "^5.0.0",
"@hapi/hapi": "^20.0.3",
"@hapi/lab": "24.1.0"
},

@@ -35,0 +34,0 @@ "directories": {

@@ -308,2 +308,40 @@ 'use strict';

});
it('Allows chaining onPreResponse when not modifying the error response', async () => {
const server2 = Hapi.Server();
await server2.register([{
plugin: require('../'),
options: { errors: Errors }
}]);
// BoomBox does it's thing in an onPreResponse extension
// But we still want to allow other pre responses to run when BoomBox doesn't do anything
server2.ext('onPreResponse', (request, h) => {
request.response.output.payload.thisMustThere = true;
return h.continue;
});
server2.route([{
method: 'POST',
path: '/error',
config: {
handler: () => {
throw new Error('500');
}
}
}]);
const response = await server2.inject({
method: 'POST',
url: '/error'
});
expect(response.statusCode).to.equal(500);
expect(response.result.thisMustThere).to.be.true();
});
});

@@ -310,0 +348,0 @@

Sorry, the diff of this file is not supported yet

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