diff options
Diffstat (limited to 'node_modules/har-validator/lib')
-rw-r--r-- | node_modules/har-validator/lib/async.js | 105 | ||||
-rw-r--r-- | node_modules/har-validator/lib/error.js | 17 | ||||
-rw-r--r-- | node_modules/har-validator/lib/promise.js | 102 |
3 files changed, 0 insertions, 224 deletions
diff --git a/node_modules/har-validator/lib/async.js b/node_modules/har-validator/lib/async.js deleted file mode 100644 index 90701f2..0000000 --- a/node_modules/har-validator/lib/async.js +++ /dev/null @@ -1,105 +0,0 @@ -var Ajv = require('ajv') -var HARError = require('./error') -var schemas = require('har-schema') - -var ajv - -function createAjvInstance () { - var ajv = new Ajv({ - allErrors: true - }) - ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json')) - ajv.addSchema(schemas) - - return ajv -} - -function validate (name, data, next) { - data = data || {} - - // validator config - ajv = ajv || createAjvInstance() - - var validate = ajv.getSchema(name + '.json') - - var valid = validate(data) - - // callback? - if (typeof next === 'function') { - return next(!valid ? new HARError(validate.errors) : null, valid) - } - - return valid -} - -exports.afterRequest = function (data, next) { - return validate('afterRequest', data, next) -} - -exports.beforeRequest = function (data, next) { - return validate('beforeRequest', data, next) -} - -exports.browser = function (data, next) { - return validate('browser', data, next) -} - -exports.cache = function (data, next) { - return validate('cache', data, next) -} - -exports.content = function (data, next) { - return validate('content', data, next) -} - -exports.cookie = function (data, next) { - return validate('cookie', data, next) -} - -exports.creator = function (data, next) { - return validate('creator', data, next) -} - -exports.entry = function (data, next) { - return validate('entry', data, next) -} - -exports.har = function (data, next) { - return validate('har', data, next) -} - -exports.header = function (data, next) { - return validate('header', data, next) -} - -exports.log = function (data, next) { - return validate('log', data, next) -} - -exports.page = function (data, next) { - return validate('page', data, next) -} - -exports.pageTimings = function (data, next) { - return validate('pageTimings', data, next) -} - -exports.postData = function (data, next) { - return validate('postData', data, next) -} - -exports.query = function (data, next) { - return validate('query', data, next) -} - -exports.request = function (data, next) { - return validate('request', data, next) -} - -exports.response = function (data, next) { - return validate('response', data, next) -} - -exports.timings = function (data, next) { - return validate('timings', data, next) -} diff --git a/node_modules/har-validator/lib/error.js b/node_modules/har-validator/lib/error.js deleted file mode 100644 index f2618dc..0000000 --- a/node_modules/har-validator/lib/error.js +++ /dev/null @@ -1,17 +0,0 @@ -function HARError (errors) { - var message = 'validation failed' - - this.name = 'HARError' - this.message = message - this.errors = errors - - if (typeof Error.captureStackTrace === 'function') { - Error.captureStackTrace(this, this.constructor) - } else { - this.stack = (new Error(message)).stack - } -} - -HARError.prototype = Error.prototype - -module.exports = HARError diff --git a/node_modules/har-validator/lib/promise.js b/node_modules/har-validator/lib/promise.js deleted file mode 100644 index 46f4647..0000000 --- a/node_modules/har-validator/lib/promise.js +++ /dev/null @@ -1,102 +0,0 @@ -var Ajv = require('ajv') -var HARError = require('./error') -var schemas = require('har-schema') - -var ajv - -function createAjvInstance () { - var ajv = new Ajv({ - allErrors: true - }) - ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json')) - ajv.addSchema(schemas) - - return ajv -} - -function validate (name, data) { - data = data || {} - - // validator config - ajv = ajv || createAjvInstance() - - var validate = ajv.getSchema(name + '.json') - - return new Promise(function (resolve, reject) { - var valid = validate(data) - - !valid ? reject(new HARError(validate.errors)) : resolve(data) - }) -} - -exports.afterRequest = function (data) { - return validate('afterRequest', data) -} - -exports.beforeRequest = function (data) { - return validate('beforeRequest', data) -} - -exports.browser = function (data) { - return validate('browser', data) -} - -exports.cache = function (data) { - return validate('cache', data) -} - -exports.content = function (data) { - return validate('content', data) -} - -exports.cookie = function (data) { - return validate('cookie', data) -} - -exports.creator = function (data) { - return validate('creator', data) -} - -exports.entry = function (data) { - return validate('entry', data) -} - -exports.har = function (data) { - return validate('har', data) -} - -exports.header = function (data) { - return validate('header', data) -} - -exports.log = function (data) { - return validate('log', data) -} - -exports.page = function (data) { - return validate('page', data) -} - -exports.pageTimings = function (data) { - return validate('pageTimings', data) -} - -exports.postData = function (data) { - return validate('postData', data) -} - -exports.query = function (data) { - return validate('query', data) -} - -exports.request = function (data) { - return validate('request', data) -} - -exports.response = function (data) { - return validate('response', data) -} - -exports.timings = function (data) { - return validate('timings', data) -} |