Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
hapi-boombox
Advanced tools
Hapi plugin Boom wrapper
Boombox allows you to create Boom errors and errors from a given errors set.
This can be used to have errors in your code that uses generic keys e.g. USER_NO_ACCESS
and it will be translated to a Boom error with a decent message e.g. You have no access to this method
.
Boombox also allows you to specify the type of Boom error. e.g. USER_NO_ACCESS
can be defined as a methodNotAllowed
and it will automaticlly generate a Boom error with the right statuscode.
You can pass anything into the boom method. Boombox will try to match an error from the errors file and otherwise generate another Boom error.
You pass some options into the method.
returnError
- If false
will return only the error message. If convert
is true Boombox will try to convert to an error first (matched from errors or general error)convert
- If false
will not try to convert to a Boom error. If returnError
is true
will generate a generic ErrorIf you try to convert a non existing key into a Boom error it will generate a Internal Server Error
error. This is by design (atm) to make sure you notice it when you use an non implemented error key.
Both methods will do a server.log
with hapi-boombox
as tag and the result as data.
reply.boom
logs some aditional data:
error
: the restult of Boombox,data
: 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
and name
.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.
Just do reply.boom(err);
for your errors and you are sure to pass a decent error to your user.
FAQs
Boom error wrapper
The npm package hapi-boombox receives a total of 0 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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.