From 3c5cb44932872c45a4b89fb50c759d101e1935f4 Mon Sep 17 00:00:00 2001 From: snyk-bot Date: Thu, 24 Dec 2020 07:12:09 +0000 Subject: [PATCH 1/2] fix: examples/typescript-ex/package.json to reduce vulnerabilities The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-JS-AXIOS-1038255 Signed-off-by: Lucas Holmquist --- examples/typescript-ex/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/typescript-ex/package.json b/examples/typescript-ex/package.json index 7a2c9c48..d9d19123 100644 --- a/examples/typescript-ex/package.json +++ b/examples/typescript-ex/package.json @@ -28,6 +28,6 @@ "typescript": "~3.9.5" }, "dependencies": { - "cloudevents": "~3.1.0" + "cloudevents": "~4.0.0" } } From ab5332e9b7cfe8de7d4bc9a1b5d9f1255404eeeb Mon Sep 17 00:00:00 2001 From: Lucas Holmquist Date: Wed, 6 Jan 2021 09:52:26 -0500 Subject: [PATCH 2/2] chore: update example to use the 4.0 API Signed-off-by: Lucas Holmquist --- examples/typescript-ex/src/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/typescript-ex/src/index.ts b/examples/typescript-ex/src/index.ts index af084a6b..228b504b 100644 --- a/examples/typescript-ex/src/index.ts +++ b/examples/typescript-ex/src/index.ts @@ -1,4 +1,4 @@ -import { CloudEvent, CloudEventV1, Receiver } from "cloudevents"; +import { CloudEvent, CloudEventV1, HTTP } from "cloudevents"; export function doSomeStuff(): void { const myevent: CloudEventV1 = new CloudEvent({ @@ -21,7 +21,7 @@ export function doSomeStuff(): void { // Typically used with an incoming HTTP request where myevent.format() is the actual // body of the HTTP - console.log("Received structured event:", Receiver.accept(headers, myevent)); + console.log("Received structured event:", HTTP.toEvent({headers, body: myevent})); // ------ receiver binary const data = { @@ -38,8 +38,8 @@ export function doSomeStuff(): void { "ce-extension1": "extension1", }; - console.log("My binary event:", Receiver.accept(attributes, data)); - console.log("My binary event extensions:", Receiver.accept(attributes, data)); + console.log("My binary event:", HTTP.toEvent({headers: attributes, body: data})); + console.log("My binary event extensions:", HTTP.toEvent({headers: attributes, body: data})); }