Blame view
node_modules/har-validator/lib/node7/async.js
2.89 KB
f7563de62
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.validate = validate; exports.afterRequest = afterRequest; exports.beforeRequest = beforeRequest; exports.browser = browser; exports.cache = cache; exports.content = content; exports.cookie = cookie; exports.creator = creator; exports.entry = entry; exports.har = har; exports.header = header; exports.log = log; exports.page = page; exports.pageTimings = pageTimings; exports.postData = postData; exports.query = query; exports.request = request; exports.response = response; exports.timings = timings; var _harSchema = require('har-schema'); var schemas = _interopRequireWildcard(_harSchema); var _ajv = require('ajv'); var _ajv2 = _interopRequireDefault(_ajv); var _error = require('./error'); var _error2 = _interopRequireDefault(_error); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } let ajv; function validate(name, data = {}, next) { // validator config ajv = ajv || new _ajv2.default({ allErrors: true, schemas: schemas }); let validate = ajv.getSchema(name + '.json'); let valid = validate(data); // callback? if (typeof next === 'function') { return next(!valid ? new _error2.default(validate.errors) : null, valid); } return valid; } function afterRequest(data, next) { return validate('afterRequest', data, next); } function beforeRequest(data, next) { return validate('beforeRequest', data, next); } function browser(data, next) { return validate('browser', data, next); } function cache(data, next) { return validate('cache', data, next); } function content(data, next) { return validate('content', data, next); } function cookie(data, next) { return validate('cookie', data, next); } function creator(data, next) { return validate('creator', data, next); } function entry(data, next) { return validate('entry', data, next); } function har(data, next) { return validate('har', data, next); } function header(data, next) { return validate('header', data, next); } function log(data, next) { return validate('log', data, next); } function page(data, next) { return validate('page', data, next); } function pageTimings(data, next) { return validate('pageTimings', data, next); } function postData(data, next) { return validate('postData', data, next); } function query(data, next) { return validate('query', data, next); } function request(data, next) { return validate('request', data, next); } function response(data, next) { return validate('response', data, next); } function timings(data, next) { return validate('timings', data, next); } |