async.js
1.91 KB
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
import * as schemas from 'har-schema'
import Ajv from 'ajv'
import HARError from './error'
let ajv
export function validate (name, data = {}, next) {
// validator config
ajv = ajv || new Ajv({
allErrors: true,
schemas: schemas
})
let validate = ajv.getSchema(name + '.json')
let valid = validate(data)
// callback?
if (typeof next === 'function') {
return next(!valid ? new HARError(validate.errors) : null, valid)
}
return valid
}
export function afterRequest (data, next) {
return validate('afterRequest', data, next)
}
export function beforeRequest (data, next) {
return validate('beforeRequest', data, next)
}
export function browser (data, next) {
return validate('browser', data, next)
}
export function cache (data, next) {
return validate('cache', data, next)
}
export function content (data, next) {
return validate('content', data, next)
}
export function cookie (data, next) {
return validate('cookie', data, next)
}
export function creator (data, next) {
return validate('creator', data, next)
}
export function entry (data, next) {
return validate('entry', data, next)
}
export function har (data, next) {
return validate('har', data, next)
}
export function header (data, next) {
return validate('header', data, next)
}
export function log (data, next) {
return validate('log', data, next)
}
export function page (data, next) {
return validate('page', data, next)
}
export function pageTimings (data, next) {
return validate('pageTimings', data, next)
}
export function postData (data, next) {
return validate('postData', data, next)
}
export function query (data, next) {
return validate('query', data, next)
}
export function request (data, next) {
return validate('request', data, next)
}
export function response (data, next) {
return validate('response', data, next)
}
export function timings (data, next) {
return validate('timings', data, next)
}