@@ -7,18 +7,18 @@ const Commons = require("./commons.js");
7
7
const structured = "structured" ;
8
8
const binary = "binary" ;
9
9
10
- const receiver_by_binding = {
10
+ const receiverByBinding = {
11
11
structured : new StructuredReceiver ( ) ,
12
12
binary : new BinaryReceiver ( ) ,
13
13
} ;
14
14
15
- const allowed_binary_content_types = [ ] ;
16
- allowed_binary_content_types . push ( Constants . MIME_JSON ) ;
15
+ const allowedBinaryContentTypes = [ ] ;
16
+ allowedBinaryContentTypes . push ( Constants . MIME_JSON ) ;
17
17
18
- const allowed_structured_content_types = [ ] ;
19
- allowed_structured_content_types . push ( Constants . MIME_CE_JSON ) ;
18
+ const allowedStructuredContentTypes = [ ] ;
19
+ allowedStructuredContentTypes . push ( Constants . MIME_CE_JSON ) ;
20
20
21
- function validate_args ( payload , headers ) {
21
+ function validateArgs ( payload , headers ) {
22
22
if ( ! payload ) {
23
23
throw { message : "payload is null or undefined" } ;
24
24
}
@@ -29,19 +29,19 @@ function validate_args(payload, headers) {
29
29
}
30
30
31
31
// Is it binary or structured?
32
- function resolve_binding_name ( payload , headers ) {
32
+ function resolveBindingName ( payload , headers ) {
33
33
34
34
var contentType = headers [ Constants . HEADER_CONTENT_TYPE ] ;
35
35
if ( contentType . startsWith ( Constants . MIME_CE ) ) {
36
36
// Structured
37
- if ( allowed_structured_content_types . includes ( contentType ) ) {
37
+ if ( allowedStructuredContentTypes . includes ( contentType ) ) {
38
38
return structured ;
39
39
} else {
40
40
throw { message : "structured+type not allowed" , errors : [ contentType ] } ;
41
41
}
42
42
} else {
43
43
// Binary
44
- if ( allowed_binary_content_types . includes ( contentType ) ) {
44
+ if ( allowedBinaryContentTypes . includes ( contentType ) ) {
45
45
return binary ;
46
46
} else {
47
47
throw { message : "content type not allowed" , errors : [ contentType ] } ;
@@ -56,20 +56,20 @@ var Unmarshaller = function() {
56
56
Unmarshaller . prototype . unmarshall = function ( payload , headers ) {
57
57
return new Promise ( ( resolve , reject ) => {
58
58
try {
59
- validate_args ( payload , headers ) ;
59
+ validateArgs ( payload , headers ) ;
60
60
61
- var sanity_headers = Commons . sanity_and_clone ( headers ) ;
61
+ var sanityHeaders = Commons . sanity_and_clone ( headers ) ;
62
62
63
63
// Validation level 1
64
- if ( ! sanity_headers [ Constants . HEADER_CONTENT_TYPE ] ) {
64
+ if ( ! sanityHeaders [ Constants . HEADER_CONTENT_TYPE ] ) {
65
65
throw { message : "content-type header not found" } ;
66
66
}
67
67
68
68
// Resolve the binding
69
- var binding_name = resolve_binding_name ( payload , sanity_headers ) ;
69
+ var bindingName = resolveBindingName ( payload , sanityHeaders ) ;
70
70
71
71
var cloudevent =
72
- receiver_by_binding [ binding_name ] . parse ( payload , sanity_headers ) ;
72
+ receiverByBinding [ bindingName ] . parse ( payload , sanityHeaders ) ;
73
73
74
74
resolve ( cloudevent ) ;
75
75
} catch ( e ) {
0 commit comments