toxy
Version:
Hackable HTTP proxy to simulate server failure scenarios and network conditions
17 lines (13 loc) • 381 B
JavaScript
const throttler = require('./throttle')
module.exports = function bandwidth (opts) {
if (typeof opts === 'number') {
opts = { bytes: opts }
}
opts = opts || {}
opts.bytes = +opts.bps || +opts.bytes || 1024
opts.threshold = +opts.threshold || 1000
const throttle = throttler(opts)
return function bandwidth (req, res, next) {
throttle(req, res, next)
}
}