2017-11-11 20:18:13 +00:00
|
|
|
const validateNpmPackageName = require('validate-npm-package-name')
|
|
|
|
const BlacklistAPI = require('../BlacklistAPI')
|
|
|
|
|
|
|
|
function removeFromBlacklist(req, res) {
|
2017-11-15 00:47:57 +00:00
|
|
|
const packageName = req.packageName
|
2017-11-11 20:18:13 +00:00
|
|
|
|
|
|
|
BlacklistAPI.removePackage(packageName).then(
|
|
|
|
removed => {
|
|
|
|
if (removed) {
|
|
|
|
const userId = req.user.jti
|
|
|
|
console.log(
|
|
|
|
`Package "${packageName}" was removed from the blacklist by ${userId}`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
res.send({
|
|
|
|
ok: true,
|
2017-11-15 00:47:57 +00:00
|
|
|
message: `Package "${packageName}" was ${
|
|
|
|
removed ? 'removed from' : 'not in'
|
|
|
|
} the blacklist`
|
2017-11-11 20:18:13 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
error => {
|
|
|
|
console.error(error)
|
2017-11-15 00:47:57 +00:00
|
|
|
|
2017-11-11 20:18:13 +00:00
|
|
|
res.status(500).send({
|
|
|
|
error: `Unable to remove "${packageName}" from the blacklist`
|
|
|
|
})
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = removeFromBlacklist
|