Skip to content

Commit ab5332e

Browse files
committed
chore: update example to use the 4.0 API
Signed-off-by: Lucas Holmquist <[email protected]>
1 parent 3c5cb44 commit ab5332e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/typescript-ex/src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CloudEvent, CloudEventV1, Receiver } from "cloudevents";
1+
import { CloudEvent, CloudEventV1, HTTP } from "cloudevents";
22

33
export function doSomeStuff(): void {
44
const myevent: CloudEventV1 = new CloudEvent({
@@ -21,7 +21,7 @@ export function doSomeStuff(): void {
2121

2222
// Typically used with an incoming HTTP request where myevent.format() is the actual
2323
// body of the HTTP
24-
console.log("Received structured event:", Receiver.accept(headers, myevent));
24+
console.log("Received structured event:", HTTP.toEvent({headers, body: myevent}));
2525

2626
// ------ receiver binary
2727
const data = {
@@ -38,8 +38,8 @@ export function doSomeStuff(): void {
3838
"ce-extension1": "extension1",
3939
};
4040

41-
console.log("My binary event:", Receiver.accept(attributes, data));
42-
console.log("My binary event extensions:", Receiver.accept(attributes, data));
41+
console.log("My binary event:", HTTP.toEvent({headers: attributes, body: data}));
42+
console.log("My binary event extensions:", HTTP.toEvent({headers: attributes, body: data}));
4343

4444
}
4545

0 commit comments

Comments
 (0)