Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
The boom npm package is a set of utilities for returning HTTP errors. It is part of the hapi ecosystem and provides a way to send error responses that include a friendly error message, the correct HTTP status code, and any additional error information.
Creating HTTP-friendly error objects
Boom allows you to create error objects that are suitable for HTTP responses. For example, you can create a 400 Bad Request error using Boom.badRequest('Invalid request payload input').
{"statusCode": 400, "error": "Bad Request", "message": "Invalid request payload input"}
Decorating error objects
Boom provides a way to decorate error objects with additional information. You can add custom data to an error using Boom.badRequest('Invalid request payload input').data({ custom: 'info' }).
{"statusCode": 400, "error": "Bad Request", "message": "Invalid request payload input", "data": {"custom": "info"}}
Generating errors for various HTTP status codes
Boom has methods for generating errors corresponding to most HTTP status codes, such as Boom.notFound('Resource not found') for a 404 error, or Boom.internal('An internal server error occurred') for a 500 error.
[{"statusCode": 404, "error": "Not Found", "message": "Resource not found"}, {"statusCode": 500, "error": "Internal Server Error", "message": "An internal server error occurred"}]
The http-errors package is similar to boom in that it allows you to create HTTP error objects. It is middleware-friendly and can be used with frameworks like Express. Unlike boom, it does not have a dependency on the hapi ecosystem.
api-error-handler is an Express middleware for handling API errors. It formats error responses in a consistent structure. While it is similar to boom in handling errors, it is specifically designed for Express and is used as middleware rather than a standalone error object generator.
HTTP-friendly error objects
#List of friendly errors available
###Boom.badRequest
example payload for Boom.badRequest('your message');
{
"statusCode": 400,
"error": "Bad Request",
"message": "your message"
}
###Boom.unauthorized
example payload for Boom.unauthorized('your message');
{
"statusCode": 401,
"error": "Unauthorized",
"message": "your message"
}
###Boom.forbidden
example payload for Boom.forbidden('your message');
{
"statusCode": 403,
"error": "Forbidden",
"message": "your message"
}
###Boom.notFound
example payload for Boom.notFound('your message');
{
"statusCode": 404,
"error": "Not Found",
"message": "your message"
}
###Boom.methodNotAllowed
example payload for Boom.methodNotAllowed('your message');
{
"statusCode": 405,
"error": "Method Not Allowed",
"message": "your message"
}
###Boom.notAcceptable
example payload for Boom.notAcceptable('your message');
{
"statusCode": 406,
"error": "Not Acceptable",
"message": "your message"
}
###Boom.proxyAuthRequired
example payload for Boom.proxyAuthRequired('your message');
{
"statusCode": 407,
"error": "Proxy Authentication Required",
"message": "your message"
}
###Boom.clientTimeout
example payload for Boom.clientTimeout('your message');
{
"statusCode": 408,
"error": "Request Time-out",
"message": "your message"
}
###Boom.conflict
example payload for Boom.conflict('your message');
{
"statusCode": 409,
"error": "Conflict",
"message": "your message"
}
###Boom.resourceGone
example payload for Boom.resourceGone('your message');
{
"statusCode": 410,
"error": "Gone",
"message": "your message"
}
###Boom.lengthRequired
example payload for Boom.lengthRequired('your message');
{
"statusCode": 411,
"error": "Length Required",
"message": "your message"
}
###Boom.preconditionFailed
example payload for Boom.preconditionFailed('your message');
{
"statusCode": 412,
"error": "Precondition Failed",
"message": "your message"
}
###Boom.entityTooLarge
example payload for Boom.entityTooLarge('your message');
{
"statusCode": 413,
"error": "Request Entity Too Large",
"message": "your message"
}
###Boom.uriTooLong
example payload for Boom.uriTooLong('your message');
{
"statusCode": 414,
"error": "Request-URI Too Large",
"message": "your message"
}
###Boom.unsupportedMediaType
example payload for Boom.unsupportedMediaType('your message');
{
"statusCode": 415,
"error": "Unsupported Media Type",
"message": "your message"
}
###Boom.rangeNotSatisfiable
example payload for Boom.rangeNotSatisfiable('your message');
{
"statusCode": 416,
"error": "Requested Range Not Satisfiable",
"message": "your message"
}
###Boom.expectationFailed
example payload for Boom.expectationFailed('your message');
{
"statusCode": 417,
"error": "Expectation Failed",
"message": "your message"
}
###Boom.notImplemented
example payload for Boom.notImplemented('your message');
{
"statusCode": 501,
"error": "Not Implemented",
"message": "An internal server error occurred"
}
###Boom.badGateway
example payload for Boom.badGateway('your message');
{
"statusCode": 502,
"error": "Bad Gateway",
"message": "An internal server error occurred"
}
###Boom.serverTimeout
example payload for Boom.serverTimeout('your message');
{
"statusCode": 503,
"error": "Service Unavailable",
"message": "An internal server error occurred"
}
###Boom.gatewayTimeout
example payload for Boom.gatewayTimeout('your message');
{
"statusCode": 504,
"error": "Gateway Time-out",
"message": "An internal server error occurred"
}
###Boom.badImplementation
example payload for Boom.badImplementation('your message');
{
"statusCode": 500,
"error": "Internal Server Error",
"message": "An internal server error occurred"
}
FAQs
HTTP-friendly error objects
The npm package boom receives a total of 820,815 weekly downloads. As such, boom popularity was classified as popular.
We found that boom demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers 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 uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.