Plugin implementation.
Plugin implementation.
Note that's an async function.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fastify |
object | Fastify instance | ||
options |
object |
<optional> |
{} | plugin configuration options
|
Methods
(inner) serialize(eventnon-null, optionsopt) → {string}
Serialize the given CloudEvent in JSON format.
Serialize the given CloudEvent in JSON format.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
event |
object | the CloudEvent to serialize | ||
options |
object |
<optional> |
{} | optional serialization attributes:
|
Throws:
-
-
if event is undefined or null, or an option is undefined/null/wrong
- Type
- Error
-
-
-
if onlyValid is true, and the given event is not a valid CloudEvent instance
- Type
- Error
-
Returns:
the serialized event, as a string
- Type
- string
(inner) validate(eventnon-null, optionsopt) → {object}
Validate the given CloudEvent with the schema compiler already instanced.
Validate the given CloudEvent with the schema compiler already instanced.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
event |
object | the CloudEvent to validate | ||
options |
object |
<optional> |
null | Ajv validation options, see Options - AJV Validator |
Throws:
-
if event is undefined or null
- Type
- Error
Returns:
object with validation results: 'valid' boolean and 'errors' as array of strings or null
- Type
- object