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

express-hellban

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

express-hellban

Express.js middleware for hellbanning lusers.

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

express-hellban

Express.js middleware for hellbanning lusers.

For banned users, this middleware waits a random number of milliseconds before either responding successfully or throwing a 500 error. Wait time range, failure rate, and success/failure behavior is configurable


// get the module loaded
var hellban = require('express-hellban');

// create a function to test whether or not a user is banned
var isBanned = function() {
  if(!req.user) {
    return true;
  else {
    return req.user.isBanned; // passport/everyauth middleware generally set req.user
  }
}

// Put this before the rest of your routes 
// The option values you see below are the defaults
app.post('*', hellban(isBanned, {
  log: false,
  failureRate: 1.0,
  minWaitTime: 5000,
  maxWaitTime: 10000,
  onSuccess: function(req, res, next) { next(); }, // just go to the next matching route
  onFailure: function(req, res, next) { res.send(500); } // HTTP 500 error
}));

FAQs

Package last updated on 07 Dec 2012

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