Skip to content

Commit

Permalink
Merge pull request #13 from mileszim/v2
Browse files Browse the repository at this point in the history
V2
  • Loading branch information
mileszim authored Apr 29, 2018
2 parents 9dfbc30 + b6d1504 commit d463706
Show file tree
Hide file tree
Showing 15 changed files with 4,255 additions and 2,524 deletions.
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"presets": [["env", {
"targets": {
"node": ["4.0"]
}
}]],
"comments": false,
"minified": false
}
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: node_js
node_js:
- "0.12"
- "4"
- "5"
- "6"
Expand Down
40 changes: 0 additions & 40 deletions Gruntfile.js

This file was deleted.

6 changes: 2 additions & 4 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
The MIT License (MIT)

Webpurify NPM Module Copyright (c) 2015 Miles Zimmerman
WebPurify Copyright (c) 2015 WebFurther, LLC.

Shakespeare Programming Language Copyright (c) 2001 Kalle Hasselström, Jon Åslund
Webpurify NPM Module Copyright (c) 2015-2018 Miles Zimmerman
WebPurify Copyright (c) 2015-2018 WebFurther, LLC.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
76 changes: 34 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ This module allows simple interaction with the WebPurify API within Node.js. For

##### Filters #####
* [check](#check)
* [checkCount](#checkCount)
* [checkCount](#checkcount)
* [replace](#replace)
* [return](#return)

##### Blacklist #####
* [addToBlacklist](#addToBlacklist)
* [removeFromBlacklist](#removeFromBlacklist)
* [getBlacklist](#getBlacklist)
* [addToBlacklist](#addtoblacklist)
* [removeFromBlacklist](#removefromblacklist)
* [getBlacklist](#getblacklist)

##### Whitelist #####
* [addToWhitelist](#addToWhitelist)
* [removeFromWhitelist](#removeFromWhitelist)
* [addToWhitelist](#addtowhitelist)
* [removeFromWhitelist](#removefromwhitelist)
* [getWhitelist](#getWhitelist)

##### Image Moderation
* [imgcheck](#imgcheck)
* [imgstatus](#imgstatus)
* [imgaccount](#imgaccount)
* [aimImgcheck](#aimImgcheck)
* [aimImgaccount](#imgaccount)
* [hybridImgcheck](#hybridImgcheck)
##### Image Moderation #####
* [imgCheck](#imgcheck)
* [imgStatus](#imgstatus)
* [imgAccount](#imgaccount)
* [aimImgCheck](#aimimgCheck)
* [aimImgAccount](#aimimgAccount)
* [hybridImgCheck](#hybridimgCheck)

# Install & Initialize #

Expand All @@ -49,8 +49,7 @@ const wp = new WebPurify({
});
```

Commands
--------
# Commands #

### check ###

Expand Down Expand Up @@ -127,7 +126,7 @@ Add a word to the blacklist.

```js
wp.addToBlacklist('my_word')
.then(success =? {
.then(success => {
if (success) { console.log('success!'); }
});
```
Expand Down Expand Up @@ -219,77 +218,70 @@ wp.getWhitelist()
});
```

Image Moderation
------
## Image Moderation ##

<a name="imgcheck" />
### imgcheck
### imgCheck ###
Use this method to submit an image to the moderation service. It will return an image ID that is used to return the results of the moderation to a callback function.

```js
wp.imgcheck('http://imageURL...')
.then(function(imgid) {
wp.imgCheck('http://imageURL...')
.then((imgid) => {
// this imgid could be used to check the status later
});
```

<a name="imgstatus" />
### imgstatus
### imgStatus ###
Returns the moderation status of an image. Possible results can be: pending, approved, declined.

```js
wp.imgstatus('imgid')
.then(function(status) {
wp.imgStatus('imgid')
.then((status) => {
// this is the status of your moderation
});
```

<a name="imgaccount" />
### imgaccount
### imgAccount ###
Check the number of image submissions remaining on your license.

```js
wp.imgaccount()
.then(function(remaining) {
wp.imgAccount()
.then((remaining) => {
// this is how many subscriptions you have to use
});
```

<a name="aimImgcheck" />
### aimImgcheck
### aimImgCheck ###
Use this method to submit an image to the WebPurify Automated Intelligent Moderation (AIM) Service. A percentage probability that the submitted image contains nudity will be returned in real-time.

```js
wp.aimImgcheck('http://imageURL...')
.then(function(nudity) {
wp.aimImgCheck('http://imageURL...')
.then((nudity) => {
if (nudity > 95) {
console.log('there\'s probably some nudity going on');
}
});
```

<a name="aimImgaccount" />
### imgaccount
### aimImgAccount ###
Check the number of AIM image submissions remaining on your license.

```js
wp.aimImgaccount()
.then(function(remaining) {
wp.aimImgAccount()
.then((remaining) => {
// this is how many subscriptions you have to use
});
```

<a name="hybridImgcheck" />
### hybridImgcheck
### hybridImgCheck ###
Combine our Automated Intelligent Moderation system (AIM) and our Live moderators to create a powerful low cost solution.

Images submitted to this method, are first sent to AIM and then sent to our live moderation team based on thresholds you set.

I.E any image that is given a 50% or greater probability by AIM can then be sent to our human moderation team for further review.

```js
wp.hybridImgcheck('http://imageURL...')
.then(function(nudity) {
wp.hybridImgCheck('http://imageURL...')
.then((nudity) => {
if (nudity > 55) {
console.log('Maybe there\'s nudity');

Expand Down
93 changes: 93 additions & 0 deletions dist/configuration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var API_PATH = '/services/rest/';
var API_HOSTS = exports.API_HOSTS = {
us: 'api1.webpurify.com',
eu: 'api1-eu.webpurify.com',
ap: 'api1-ap.webpurify.com',
im: 'im-api1.webpurify.com',
vid: 'vid-api1.webpurify.com'
};

var ENV = {
api_key: process.env.WEBPURIFY_API_KEY,
endpoint: process.env.WEBPURIFY_ENDPOINT,
enterprise: process.env.WEBPURIFY_ENTERPRISE
};

var DEFAULT_PARAMS = {
endpoint: 'us',
enterprise: false
};

var Configuration = function () {
function Configuration() {
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

_classCallCheck(this, Configuration);

if (!(params instanceof Object)) {
throw new Error('Invalid params - object required');
}
this.params = params;
}

_createClass(Configuration, [{
key: 'config',
get: function get() {
if (!this._options) {
this._config = {
api_key: this.api_key,
endpoint: this.endpoint,
enterprise: this.enterprise
};
}
return this._config;
}
}, {
key: 'api_key',
get: function get() {
var key = ENV.WEBPURIFY_API_KEY || this.params.api_key;
if (!key) {
throw new Error('api_key is a required parameter');
}
if (typeof key !== 'string') {
throw new Error('param.api_key must be of type string');
}
return key;
}
}, {
key: 'endpoint',
get: function get() {
var hosts = Object.keys(API_HOSTS);
var params_endpoint = hosts.includes(this.params.endpoint) || this.params.endpoint;
var env_endpoint = hosts.includes(ENV.endpoint) || ENV.endpoint;
return API_HOSTS[params_endpoint || env_endpoint || DEFAULT_PARAMS.endpoint];
}
}, {
key: 'enterprise',
get: function get() {
var bools = ['true', 'false'];
var params_enterprise = this.params.enterprise && bools.includes(this.params.enterprise.toString()) || this.params.enterprise;
var env_enterprise = ENV.enterprise && bools.includes(ENV.enterprise.toString()) || ENV.enterprise;
return params_enterprise || env_enterprise || DEFAULT_PARAMS.enterprise;
}
}, {
key: 'path',
get: function get() {
return API_PATH;
}
}]);

return Configuration;
}();

exports.default = Configuration;
15 changes: 15 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});

require("babel-polyfill");

var _webpurify = require("./webpurify");

var _webpurify2 = _interopRequireDefault(_webpurify);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = _webpurify2.default;
Loading

0 comments on commit d463706

Please sign in to comment.