Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
hapi-boombox
Advanced tools
Hapi error conversion and logging
Boombox logs errors and is able to transform errors. Current version targets hapi 16.
Provide Boombox with custom errors (see here for an example) when registering and it will convert errors with messages that match a key in errors
and will return a new Boom error.
const Errors = require('./test/config/errors.json'); //Look here for an example!
await server.register({
plugin: require('hapi-boombox'),
options: { errors: Errors }
}, callback);
E.g. you return new Error('RESOURCE_NOT_FOUND')
and the config states that this should return a Boom.notFound
(404). Boombox will do that for you instead of returning an internal server error.
Look at the test example to see what the config night look like.
Boombox also provides a server and request method (server.boombox()
, request.boombox()
) so you can transform your errors on the go.
Returns undefined
when matching fails.
const matched = server.boombox(new Error('RESOURCE_NOT_FOUND'));
/*
* matched
*{
* message: 'Custom error message for RESOURCE_NOT_FOUND',
* type: 'notFound'
*}
*/
You can disable the logging part by setting disableLog
to true
.
const Errors = require('./test/config/errors.json'); //Look here for an example!
await server.register({
plugin: require('hapi-boombox'),
options: { errors: Errors, disableLog: true }
}, callback);
Boombox will do a request.log
with hapi-boombox
and error
as tags and the result as data.
error
the output of the errorstack
the stacktracerequest
additional info about the request
path
, query
, method
, payload
, headers
, request.info
, credentials
credentials
: if present this will be an object that includes 2 properties from request.auth.credentials
.
id
.100% test coverage! Also look in the tests for more examples.
Personally I use this in a hapi server to use generic keys as errors in my code but to give the end user a decent error message and to easily match errors with the right error code. Maybe in the future this can also return localized errors.
FAQs
Boom error wrapper
The npm package hapi-boombox receives a total of 3 weekly downloads. As such, hapi-boombox popularity was classified as not popular.
We found that hapi-boombox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.