0.1.6 • Published 2 years ago
vindu v0.1.6
Vindu
Rate limiter for APIs.
Install
npm i vindu
Usage
const vindu = require('vindu')
const $ = { req, res, db }
function rateLimit(res) {
res.statusCode = 429
res.end('')
}
const options = {
// Requests per minute
limit: 30,
// The name of the database collection to use
collection: 'request'
}
const throttle = await vindu($, options)
if (throttle) {
return rateLimit($.res)
}
MIT Licensed. Enjoy!