unpkg/server/middleware/checkBlacklist.js

16 lines
362 B
JavaScript
Raw Normal View History

2017-08-17 06:03:28 +00:00
function checkBlacklist(blacklist) {
2017-11-08 16:57:15 +00:00
return function(req, res, next) {
2017-08-17 06:03:28 +00:00
// Do not allow packages that have been blacklisted.
if (blacklist.includes(req.packageName)) {
2017-11-08 16:57:15 +00:00
res
.status(403)
.type('text')
.send(`Package "${req.packageName}" is blacklisted`)
2017-08-17 06:03:28 +00:00
} else {
next()
}
}
}
module.exports = checkBlacklist