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

make your express application respond correctly when http requests are failing

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

anubis

Build Status

Make sure your express application responds correctly when outgoing http requests are failing

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.

Installation

$ npm install anubis --save

Usage

This is a tiny express app that will do nothing but proxy another resource. In case the call fails with a 5xx error, anubis makes sure the correct 502 status code is returned.

var express = require('express');
var rp = require('request-promise');
var anubis = require('anubis');

var app = express();

app.get('/', function(req, res, next){
	rp('http://my-unreliable-api.com')
		.then(function(payload){
			res.json({ok: true, payload: payload});
		})
		.catch(next);
});

// always make sure to mount anubis **after** all routes that call
// external resources
// pass a function that transforms the Error into a status code
app.use(anubis(function(err){
    return err.statusCode;
}));

app.use(function(err, req, res, next){ //eslint-disable-line no-unused-vars
	res.status(err.status);
	res.json({ok: false});
});

License

MIT © Frederik Ring

Keywords

FAQs

Package last updated on 27 Aug 2016

Did you know?

Socket

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.

Install

Related posts

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