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

anubis

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anubis - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

32

index.js

@@ -1,14 +0,20 @@

module.exports = function(err, req, res, next){
err = err || new Error('Internal Server Error');
var status = err.status || err.statusCode;
// if there's an internal server error returned from
// the api we won't propagate that error and
// return `502 Bad Gateway` instead
if (status && parseInt(status, 10) > 499){
err.message = 'Bad Gateway';
err.status = 502;
return next(err);
}
err.status = status || 500;
next(err);
module.exports = function(statusFromError){
return function(err, req, res, next){
err = err || new Error('Internal Server Error');
try {
var status = statusFromError(err);
} catch (err){
status = null;
}
// if there's an internal server error returned from
// the api we won't propagate that error and
// return `502 Bad Gateway` instead
if (status && parseInt(status, 10) > 499){
err.message = 'Bad Gateway';
err.status = 502;
return next(err);
}
err.status = status || 500;
next(err);
};
};
{
"name": "anubis",
"version": "1.0.0",
"version": "2.0.0",
"description": "make your express application respond correctly when http requests are failing",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -5,5 +5,5 @@ # anubis

> Make your express application respond correctly when http requests are failing
> Make sure your express application responds correctly when outgoing http requests are failing
When your express application is calling failing resources, ensure it will respond with a `502 Bad Gateway` response.
When your express application is calling failing resources, mount this middleware to ensure it will respond with a proper `502 Bad Gateway` response when needed.

@@ -37,3 +37,6 @@ ### Installation

// external resources
app.use(anubis);
// pass a function that transforms the Error into a status code
app.use(anubis(function(err){
return err.statusCode;
}));

@@ -40,0 +43,0 @@ app.use(function(err, req, res, next){ //eslint-disable-line no-unused-vars

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