node-github-webhook
Advanced tools
Comparing version 1.0.1 to 1.0.2
54
index.js
@@ -20,27 +20,2 @@ /** | ||
function create(options) { | ||
function findHandler(url, arr) { | ||
var ret = arr[0] | ||
for (var i = 0; i < arr.length; i++) { | ||
if (url.split('?').shift() === arr[i].path) | ||
ret = arr[i] | ||
} | ||
return ret | ||
} | ||
if (Array.isArray(options)) { | ||
options = findHandler(req.url, options) | ||
} | ||
if (!isObject(options)) | ||
throw new TypeError('must provide an options object') | ||
if (typeof options.path !== 'string') | ||
throw new TypeError('must provide a \'path\' option') | ||
if (typeof options.secret !== 'string') | ||
throw new TypeError('must provide a \'secret\' option') | ||
if (Array.isArray(options.events) && options.events.indexOf('*') === -1) | ||
throw new TypeError('must provide an events array') | ||
// make it an EventEmitter, sort of | ||
@@ -62,2 +37,31 @@ handler.__proto__ = EventEmitter.prototype | ||
function findHandler(url, arr) { | ||
var ret = arr[0] | ||
for (var i = 0; i < arr.length; i++) { | ||
if (url.split('?').shift() === arr[i].path) | ||
ret = arr[i] | ||
} | ||
return ret | ||
} | ||
function checkType(options) { | ||
if (!isObject(options)) | ||
throw new TypeError('must provide an options object') | ||
if (typeof options.path !== 'string') | ||
throw new TypeError('must provide a \'path\' option') | ||
if (typeof options.secret !== 'string') | ||
throw new TypeError('must provide a \'secret\' option') | ||
if (Array.isArray(options.events) && options.events.indexOf('*') === -1) | ||
throw new TypeError('must provide an events array') | ||
} | ||
if (Array.isArray(options)) { | ||
options = findHandler(req.url, options) | ||
} | ||
checkType(options) | ||
if (req.url.split('?').shift() !== options.path) | ||
@@ -64,0 +68,0 @@ return callback() |
{ | ||
"name": "node-github-webhook", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Github Webhooks handler based on Node.js. Support multiple handlers.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -12,2 +12,4 @@ # node-github-webhook | ||
Notice: Github Webhooks setting: `Content-type` must be `application/json`. | ||
### Usage | ||
@@ -14,0 +16,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8461
92
56