webpurifyFilters

node v10.21.0
version: 1.0.0
endpointsharetweet
var tonicExpress = require("@runkit/runkit/express-endpoint/1.0.0") var app = tonicExpress(module.exports) var bodyParser = require('body-parser'); var url = require('url'); app.use(bodyParser.urlencoded({ extended: false })); const WebPurify = require('webpurify'); const wp = new WebPurify({ api_key: process.env.WEBPURIFY_API_KEY }); app.get("/check/:word", (req, res) => wp.check(req.params.word).then(profanity => { if (profanity) { res.send('A bunch of sailors in here!'); } else { res.send('This is a pure string'); } }) ); app.get("/checkCount/:word", (req, res) => wp.checkCount(req.params.word) .then(profanity => { if(profanity > 0) { res.send(profanity.toString() + ' sailors in here!'); } else { res.send('This is a pure string'); } }) ); app.get("/replace/:word", (req, res) => wp.replace(req.params.word, '*') .then(purifiedText => { res.send(purifiedText); }) ); app.get("/return/:word", (req, res) => wp.replace(req.params.word, '*') .then(profanity => { for (word in profanity) { // need to work on this.. to display in array format res.send(profanity[word]); } }) ); app.get("/Options", (req, res) => /* var optional = { lang: 'en', // the 2 letter language code for the text you are submitting semail: 1, // treat email addresses like profanity sphone: 1, // treat phone numbers like profanity slink: 1 // treat urls like profanity } */ wp.check(req.params.word, optional) .then(profanity => { console.log(profanity); }) ); app.get("/addToBlacklist/:word", (req, res) => wp.addToBlacklist(req.params.word) .then(success => { if (success) { res.send('success!'); } }) ); app.get("/removeFromBlacklist/:word", (req, res) => wp.addToBlacklist(req.params.word) .then(success => { if (success) { res.send('success!'); } }) ); app.get("/getBlacklist", (req, res) => wp.getBlacklist() .then(blacklist => { /*for (word in blacklist) { console.log(blacklist[word]); }*/ res.send(blacklist); }) ); app.get("/addToWhitelist/:word", (req, res) => wp.addToWhitelist(req.params.word) .then(success => { if (success) { res.send('success!'); } }) ); app.get("/removeFromWhitelist/:word", (req, res) => wp.removeFromWhitelist(req.params.word) .then(success => { if (success) { res.send('success!'); } }) ); app.get("/getWhitelist", (req, res) => wp.getWhitelist() .then(whitelist => { /* for (word in whitelist) { console.log(whitelist[word]); }*/ res.send(whitelist); }) ); //https://untitled-a83ttfm1h62q.runkit.sh/imgCheck?url=https:/cdn.cnn.com/cnnnext/dam/assets/200129144901-02-jerome-powell-0129-exlarge-169.jpg app.get('/imgCheck', (req, res) => { var parts = url.parse(req.url, true); var imageUrl = parts.query.url; parts = url.parse(imageUrl); wp.imgCheck(parts) .then((imgid) => { res.send(imgid) }) }); //https://untitled-a83ttfm1h62q.runkit.sh/imgStatus app.get('/imgStatus', (req, res) => { wp.imgStatus(106) .then((status) => { res.send(status) }) }); app.get('/imgAccount', (req, res) => { wp.imgAccount() .then((remaining) => { res.send(remaining); // this is how many subscriptions you have to use }); }); app.get('/aimImgCheck', (req, res) => { var parts = url.parse(req.url, true); var imageUrl = parts.query.url; parts = url.parse(imageUrl); wp.aimImgCheck(parts) .then((nudity) => { if (nudity > 95) { res.send('there\'s probably some nudity going on'); } }) }); app.get('/hybridImgCheck', (req, res) => { var parts = url.parse(req.url, true); var imageUrl = parts.query.url; parts = url.parse(imageUrl); wp.hybridImgCheck('http://imageURL...') .then((nudity) => { if (nudity > 55) { re.send('Maybe there\'s nudity'); // use the customimgid parameter to poll for the live check } }) });
Loading…

no comments

    sign in to comment