Commit Graph

55 Commits

Author SHA1 Message Date
Snyk bot d3593556f1
fix: examples/typescript-ex/package.json to reduce vulnerabilities (#395)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-HOSTEDGITINFO-1088355

Signed-off-by: Lance Ball <lball@redhat.com>
2021-04-06 10:58:06 -04:00
Lance Ball 1af3d43341 fix: Emitter should not extend EventEmitter
This change modifies Emitter so that it does not directly extend the Node.js
EventEmitter class. Instead, it holds a singleton instance of an EventEmitter
but is not an instance of EventEmitter itself.

This commit also updates the typescript example to use a modern version of
@types/node and typescript.

Finally there are a few minor formatting changes picked up by eslint.

Fixes: https://github.com/cloudevents/sdk-javascript/issues/385

Signed-off-by: Lance Ball <lball@redhat.com>
2021-02-27 19:27:20 -05:00
Snyk bot 6be3b27514
fix: cloudevents from 3.2.0 to 4.0.0 (#376)
* fix: examples/express-ex/package.json to reduce vulnerabilities

The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-AXIOS-1038255

* fix(examples): remove the body-parser module.

* When a structured formatted CloudEvent comes in, the body parser module does know how to parse it since the content type is not application/json, which resulted in an empty request body

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>

Co-authored-by: Lucas Holmquist <lholmqui@redhat.com>
2021-01-06 13:46:21 -05:00
Snyk bot f8514062d4
[Snyk] Security upgrade cloudevents from 3.1.0 to 4.0.0 (#377)
* 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

* chore: update example to use the 4.0 API

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>

Co-authored-by: Lucas Holmquist <lholmqui@redhat.com>
2021-01-06 09:55:37 -05:00
Snyk bot 2b1e1ec5a2
fix: examples/websocket/package.json to reduce vulnerabilities (#375)
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/SNYK-JS-AXIOS-1038255

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2021-01-06 09:44:31 -05:00
Lucas Holmquist 7423acb7fc
fix: upgrade cloudevents from 3.0.1 to 3.1.0 (#335)
Snyk has created this PR to upgrade cloudevents from 3.0.1 to 3.1.0.

See this package in npm:
https://www.npmjs.com/package/cloudevents

See this project in Snyk:
https://app.snyk.io/org/lance/project/cb2960b0-db0c-4e77-9ab2-e78efded812e?utm_source=github&utm_medium=upgrade-pr

Co-authored-by: snyk-bot <snyk-bot@snyk.io>
Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-09-03 14:52:50 -04:00
Philip Hayes 4779d89ad0
chore(example): Replaced body parser with express JSON parser (#334)
Signed-off-by: Philip Hayes <phayes@redhat.com>

Co-authored-by: Philip Hayes <phayes@redhat.com>
2020-09-02 17:09:53 -04:00
Lance Ball f3953a9a5a
feat: introduce Message, Serializer, Deserializer and Binding interfaces (#324)
* lib(messages): Implement a 4.0 Messages and other supporting interfaces

This commit introduces the Message, Serializer and Deserializer, and Binding
interfaces used to convert a CloudEvent into a Message that can be sent across
a transport protocol. The first protocol implemented for this is HTTP, and some
of the functionality formerly in src/transport/http has been simplified,
reduced and/or moved to /src/messages/http.

Test for V1 and V3 events are in place. Conformance tests have been modified to use
these new interfaces vs. the HTTP Receiver class.

Signed-off-by: Lance Ball <lball@redhat.com>
2020-08-26 18:26:50 -04:00
Grant Timmerman d590e3a007
docs: improve readme receiver example (#309)
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-08-11 09:31:05 -04:00
Lucas Holmquist 48d182bc5f
fix: update browser name to cloudevents. (#292)
* This updates the broswer based version to cloudevents instead of cloudevents-sdk.

Fixes: #286

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-07-30 13:55:57 -04:00
Lucas Holmquist 763838c89c
chore: Update examples to use latest sdk changes (#282)
* This updates all the examples to use the latest module version(3.0.0)


Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-07-30 09:24:02 -04:00
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
Lance Ball 99bb88be00
examples: add a WebSocket example (#218)
There is nothing really to do in order to support events over websockets.
Since a `CloudEvent` can easily be represented in full with JSON, it can
be sent over a websocket as `event.toString()`. This example illustrates
sending a `CloudEvent` over websocket from a browser or CLI.

Fixes: https://github.com/cloudevents/sdk-javascript/issues/156
Signed-off-by: Lance Ball <lball@redhat.com>
2020-06-10 17:50:35 -04:00
Lucas Holmquist dcb3c4e98a
chore: Update examples to use the latest sdk version(2.0.2) (#206)
Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-06-09 18:08:15 -04:00
Lucas Holmquist ed1d3286fa
docs: Update references of specific versions to use Latest Supported. (#211)
* docs: Update references of specific versions to use Latest Supported.

fixes #160

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
2020-06-08 15:47:30 -04:00
Lance Ball a5befbe0cf
fix: introduce CloudEventV1 and CloudEventV03 interfaces (#194)
This extracts all of the attributes from a `CloudEventVX` that
are not generated by the constructor (id and specversion) into their
own `CloudEventVXAttributes` interface which the `CloudEventVX`
interface extends. This allows TS devs to optionally provide `id`
and `specversion` with proper autocompletion.

Additionally, I have added a union type, `CE` in `cloudevent.ts` which
represents any of `CloudEventV1`, `CloudEventv03`, `CloudEventV1Attributes`
and `CloudEventV03Attributes` interfaces.

Finally, this commit changes all of the user facing API to be `.ts` instead
of `.js` files.

The existing documentation in `./docs` was removed. It should be replaced with generated
HTML from tsdocs, pending some other method of publishing API documentation. That will
come as a separate, docs-only PR.

Fixes: https://github.com/cloudevents/skd-javascript/issues/188

Signed-off-by: Lance Ball <lball@redhat.com>
2020-05-29 17:49:02 -04:00
Lance Ball b866edddd9
docs: update README and examples with new API (#138)
This commit modifies the README to show new API usage for the
`HTTPReceiver` and `CloudEvent` classes, and updates the examples
to use this as well.

Overall structure and content has been modified to look more like
the sdk-go README.

Fixes: https://github.com/cloudevents/sdk-javascript/issues/128

Signed-off-by: Lance Ball <lball@redhat.com>
2020-05-11 09:41:05 -04:00
Grant Timmerman 05ecbdea4f
feat: use CloudEvents not cloudevents everywhere (#101)
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
2020-04-30 16:14:13 -07:00
Helio Frota bb8e0f9e0c
fix: Fix Express example installation (#77)
Signed-off-by: Helio Frota <00hf11@gmail.com>
2020-04-29 10:44:02 -07:00
Lance Ball 5110ad4c67 src,fix: drop support for v0.2 and clean up contenttype
This commit removes support for the v0.2 specification. It also removes the
`contenttype` attribute from the `CloudEvent` object. While the HTTP protocol
binding specifies that in binary mode, the `datacontenttype` attribute should
map to the HTTP Content-Type header, that doesn't mean that the `CloudEvent`
object should have a `contenttype` property.

Fixes: https://github.com/cloudevents/sdk-javascript/issues/61
Fixes: https://github.com/cloudevents/sdk-javascript/issues/66

Signed-off-by: Lance Ball <lball@redhat.com>
2020-04-28 17:37:49 -03:00
Lance Ball 3f238a0124
src: add eslint configuration and npm script
Automatically fixed > 2000 issues. The remaining 200+ issues need
to be fixed by hand. Additionally, all strings are double quotes
which is not typically standard and I wonder about fixing that too.

Signed-off-by: Lance Ball <lball@redhat.com>
2020-04-22 10:15:05 -04:00
Fabio José a7e8354d56 Set the version of sdk to 1.0.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-06 11:22:04 -03:00
Fabio José 36d61f190e Express examples with Spev 1.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-06 11:21:53 -03:00
Fabio José 03f8796b3f Examples of payload using spec 1.0
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-06 11:20:41 -03:00
Fabio José c35af5b66e Fix link to requestbin
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-04 10:00:30 -03:00
Fabio José 807d60462b ts Example using binary receiver
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-11-04 09:54:16 -03:00
Fabio José 0d8c8a13ae ts example with binary emitter
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-29 21:43:21 -03:00
Fabio José b4b04963b9 Typescript examples
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-10-29 20:49:54 -03:00
Fabio José 06927a9fac Lock of package for examples
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-07 12:37:03 -03:00
Fabio José 83adbf1ee0 Fix reference to cloudevents-sdk
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-07 12:36:23 -03:00
Fabio José 7bdd116b1f Add line feed
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 12:25:50 -03:00
Fabio José 2cdbbc9d98 Node package lock of examples
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 12:25:35 -03:00
Fabio José c8675ca103 Fix the unmashaller import
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 12:25:25 -03:00
Fabio José 2b48302bad Node package lock of examples
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 12:05:56 -03:00
Fabio José 762f77ce0b Base 64 data example
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 11:22:56 -03:00
Fabio José 6f2cbd61e4 Document example for spec 0.3
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 11:22:27 -03:00
Fabio José a9dc14f617 Expose the /v02 for spec 0.2 and /v03 for spec 0.3
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 11:21:57 -03:00
Fabio José d38c857c03 Identify the example payload
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-06 11:21:24 -03:00
Fabio José 10fbc1df7a Import the new way of require specifications
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-05 15:11:39 -03:00
Fabio José e602736c20 Spec v0.3 examples
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-08-05 15:10:50 -03:00
Fabio José 852cad0832 Fix the examples and use the same names
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-25 12:08:04 -03:00
Fabio José e1b04bdcdb Change to use promise
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-25 12:05:02 -03:00
Fabio José c7341baf96 Example for structured with extension
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-25 11:08:09 -03:00
Fabio José 1497934bed Example of payload with extenstion
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-25 11:07:56 -03:00
Fabio José b12c6d75d4 fix type, ex with extension
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-25 11:05:00 -03:00
Fabio José b39a32152f Double quotes
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-25 11:02:14 -03:00
Fabio José 6c5b7e2c86 When incorrect, reply the errors too
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-25 10:54:39 -03:00
Fabio José 99310d1920 Fix binary example
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-21 16:48:08 -03:00
Fabio José 5baa52dd2b Fix example body read
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-21 16:43:25 -03:00
Fabio José 365e0871b7 Fix binary data attribute example
Signed-off-by: Fabio José <fabiojose@gmail.com>
2019-06-21 16:42:55 -03:00