sdk-javascript/examples/express-ex
Lance Ball 276b810dd8
BREAKING CHANGE(lib): rewrite in TypeScript (#226)
This is a major rewrite of the entire codebase into TypeScript. Nearly
all tests have been retained except where behavior is significantly
different. Some highlights of these changes:

* lowercase all CloudEvent properties and fix base64 encoded data

Previously there was a format() function that would convert a CloudEvent
object into JSON with all of the properties lowercased. With this rewrite
a CloudEvent object can be converted to JSON simply with JSON.stringify().

However, in order to be compliant with the JSON representation outlined in
the spec here https://github.com/cloudevents/spec/blob/v1.0/json-format.md
all of the event properties must be all lowercase.

* lib(transport): make transport mode an Enum
* src: allow custom headers (#1)
* lib(exports): export explicitly versioned names where appropriate
* lib(cloudevent): modify ctor to accept extensions inline
* lib(cloudevent): make extensions a part of the event object
* test: convert all tests to typescript
* examples: update all examples with latest API changes
* docs: update README with latest API changes
* src: add prettier for code style and fix a lot of linting errors
* lib: move data decoding to occur within the CloudEvent object

Signed-off-by: Lance Ball <lball@redhat.com>
2020-06-29 14:46:20 -04:00
..
README.md docs: Update references of specific versions to use Latest Supported. (#211) 2020-06-08 15:47:30 -04:00
index.js BREAKING CHANGE(lib): rewrite in TypeScript (#226) 2020-06-29 14:46:20 -04:00
package.json chore: Update examples to use the latest sdk version(2.0.2) (#206) 2020-06-09 18:08:15 -04:00

README.md

Express Example

How To Start

npm start

Latest Supported Spec (v1.0)

A Structured One

Payload example

curl -X POST \
     -d'@../payload/v1/structured-event-0.json' \
     -H'Content-Type:application/cloudevents+json' \
     http://localhost:3000/

A Structured One with Extension

Payload example

curl -X POST \
     -d'@../payload/v1/structured-event-1.json' \
     -H'Content-Type:application/cloudevents+json' \
     http://localhost:3000/

A Structured One with Base64 Event Data

Payload example

curl -X POST \
     -d'@../payload/v1/structured-event-2.json' \
     -H'Content-Type:application/cloudevents+json' \
     http://localhost:3000/

A Binary One

curl -X POST \
     -d'@../payload/data-0.json' \
     -H'Content-Type:application/json' \
     -H'ce-specversion:1.0' \
     -H'ce-type:com.github.pull.create' \
     -H'ce-source:https://github.com/cloudevents/spec/pull/123' \
     -H'ce-id:45c83279-c8a1-4db6-a703-b3768db93887' \
     -H'ce-time:2019-11-06T11:17:00Z' \
     http://localhost:3000/

A Binary One with Extension

curl -X POST \
     -d'@../payload/data-0.json' \
     -H'Content-Type:application/json' \
     -H'ce-specversion:1.0' \
     -H'ce-type:com.github.pull.create' \
     -H'ce-source:https://github.com/cloudevents/spec/pull/123' \
     -H'ce-id:45c83279-c8a1-4db6-a703-b3768db93887' \
     -H'ce-time:2019-11-06T11:17:00Z' \
     -H'ce-my-extension:extension value' \
     http://localhost:3000/

A Binary One with Base 64 Encoding

curl -X POST \
     -d'@../payload/data-1.txt' \
     -H'Content-Type:application/json' \
     -H'ce-specversion:1.0' \
     -H'ce-type:com.github.pull.create' \
     -H'ce-source:https://github.com/cloudevents/spec/pull/123' \
     -H'ce-id:45c83279-c8a1-4db6-a703-b3768db93887' \
     -H'ce-time:2019-11-06T11:17:00Z' \
     http://localhost:3000/

Spec v0.3

A Structured One

Payload example

curl -X POST \
     -d'@../payload/v03/structured-event-0.json' \
     -H'Content-Type:application/cloudevents+json' \
     http://localhost:3000/

A Structured One with Extension

Payload example

curl -X POST \
     -d'@../payload/v03/structured-event-1.json' \
     -H'Content-Type:application/cloudevents+json' \
     http://localhost:3000/

A Binary One

curl -X POST \
     -d'@../payload/data-0.json' \
     -H'Content-Type:application/json' \
     -H'ce-specversion:0.3' \
     -H'ce-type:com.github.pull.create' \
     -H'ce-source:https://github.com/cloudevents/spec/pull/123' \
     -H'ce-id:45c83279-c8a1-4db6-a703-b3768db93887' \
     -H'ce-time:2019-06-21T17:31:00Z' \
     http://localhost:3000/

A Binary One with Extension

curl -X POST \
     -d'@../payload/data-0.json' \
     -H'Content-Type:application/json' \
     -H'ce-specversion:0.3' \
     -H'ce-type:com.github.pull.create' \
     -H'ce-source:https://github.com/cloudevents/spec/pull/123' \
     -H'ce-id:45c83279-c8a1-4db6-a703-b3768db93887' \
     -H'ce-time:2019-06-21T17:31:00Z' \
     -H'ce-my-extension:extension value' \
     http://localhost:3000/

A Binary One with Base 64 Encoding

curl -X POST \
     -d'@../payload/data-1.txt' \
     -H'Content-Type:application/json' \
     -H'ce-specversion:0.3' \
     -H'ce-type:com.github.pull.create' \
     -H'ce-source:https://github.com/cloudevents/spec/pull/123' \
     -H'ce-id:45c83279-c8a1-4db6-a703-b3768db93887' \
     -H'ce-time:2019-06-21T17:31:00Z' \
     -H'ce-datacontentencoding:base64' \
     http://localhost:3000/