This commit adds instructions and details to contributors guide and provides detailed guidance for pull requests and maintainers in separate documents.
Signed-off-by: Lance Ball <lball@redhat.com>
This commit changes the event mode detection in `HTTPReceiver` so that it will
throw a TypeError if the event mode can't be detected per the spec.
Signed-off-by: Lance Ball <lball@redhat.com>
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>
* fix: ensure binary events can handle no content-type header
The fix provided in https://github.com/cloudevents/sdk-javascript/pull/118
only included tests for `receiver.check()`, and the change in that
case was to add the `application/json` content type to the cleansed
headers if to type was specified.
However, `receiver.parse()` did not receive the benefit of this change. It
calls `this.check()` but then sanitizes the original headers again, and the
missing content-type was not re-inserted into the newly sanitized headers.
This commit, modifies the code so that `receiver.check()` does not insert
the content-type, but does allow the validation check to pass if no
content-type header exists. When `receiver.parse()` is called, and the
headers are sanitized again - and this time used to look up parser implementation,
the default `application/json` content-is applied if no content-type header
exists.
I've also removed a redundant call to `receiver.check()` in receiver_binary_1.js
and simplified the usage of `Constants` in the test.
Signed-off-by: Lance Ball <lball@redhat.com>
* chore: clean up header sniffing
Signed-off-by: Lance Ball <lball@redhat.com>
This commit removes the unnecessary use of Promises in the 0.3 unmarshaller.
There was actually no asynchronous activity happening in that function, so
there was no need to deal with Promises, and as a result testing was made
much more difficult.
Fixes: https://github.com/cloudevents/sdk-javascript/pull/95
Signed-off-by: Lance Ball <lball@redhat.com>
* fix: make application/json the default content type in binary mode (#118)
The Knative Kafka event source does not include a `Content-Type` header when
sending binary events. The CE HTTP binding specification doesn't address how
a receiver should handle this situation.
This commit makes `application/json` the default.
Fixes: https://github.com/cloudevents/sdk-javascript/issues/117
Ref: https://github.com/cloudevents/spec/issues/614
Signed-off-by: Lance Ball <lball@redhat.com>
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
* refactor: remove ext folder
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
* Revert "fix: make application/json the default content type in binary mode (#118)"
This reverts commit 9ccfaf25ba.
Signed-off-by: Grant Timmerman <timmerman+devrel@google.com>
Co-authored-by: Lance Ball <lball@redhat.com>
Event receivers in the wild may not always know what version or mode an
incoming event is. Instead of requiring developers to inspect the headers
themselves, the SDK should provide an HTTP receiver that is capable of
figuring out what the version and mode (structured/binary) of an incoming
event is and handle it appropriately.
In determining the best way to expose this, I chose to modify the API a
little bit. Now, instead of `const CloudEvent = require('cloudevents-sdk');`
users need to destructure it.
```js
const { HTTPReceiver, CloudEvent } = require('cloudevents-sdk');
```
This change should not be backported to 1.x.
Fixes: https://github.com/cloudevents/sdk-javascript/issues/93
Signed-off-by: Lance Ball <lball@redhat.com>
This commit updates the 0.1 and 0.3 sources to use the specversion
available in schema definitions.
Signed-off-by: Daniel Bevenius <daniel.bevenius@gmail.com>
Enforce the use of `let` and `const` by using elsint rules.
When creating the eslint configuration, I had assumed that
`extends: eslint:recommended` would have covered this, but
apparently not!
Existing usage of `var` fixed with `npm run lint -- --fix`.
Fixes: https://github.com/cloudevents/sdk-javascript/issues/97
Signed-off-by: Lance Ball <lball@redhat.com>
The code coverage publishing in package.json works fine on non-ubuntu systems.
However, in Ubuntu `/bin/sh` is symlinked to `/bin/dash` which doesn't support
everything supported by `/bin/bash` - specifically `-o pipefail`.
This commit changes the code coverage script to explicitly use `bash` instead.
Fixes: https://github.com/cloudevents/sdk-javascript/issues/81
Signed-off-by: Lance Ball <lball@redhat.com>
This commit adds the `standard-version` module for managing releases.
When running `npm run release` the following steps are taken.
1. Retreive the current version of your repository by looking at package.json.
2. Bump the version in package.json based on the commits.
3. Prepends to the CHANGELOG based on the commits (uses conventional-changelog under the hood).
4. Create a new commit including the package.json and updated CHANGELOG.
5. Create a new tag with the new version number.
This works best if all commits follow the Conventional Commits specification.
https://www.conventionalcommits.org/en/v1.0.0/
Fixes: https://github.com/cloudevents/sdk-javascript/issues/56
Signed-off-by: Lance Ball <lball@redhat.com>
This commit updates the http unmarshaller tests to use the constants
available in lib/bindings/http/constants.js.
Signed-off-by: Daniel Bevenius <daniel.bevenius@gmail.com>
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>
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>
This commit updates all of the dependencies in package.json to
their most recent versions. It also removes dependencies that were
specified in package.json but not used - or only used in a
`require()` statement.
These changes have some ripple effects. Istanbul has not been
supported for some time, so it has been replaced with nyc.
The code coverage reporting tool from codacy has been updated
as well. This could not be tested without having the API token.
Finally, the CI job has been modified to run tests on Node.js
versions 10x and 12x. All older versions of Node.js are no longer
maintained.
Signed-off-by: Lance Ball <lball@redhat.com>
This commit modifies both of the 1.0 emitters so that they may
accept typed objects as a part of the configuration. When using
mTLS in Node, you need to provide an `Agent` to the underlying
HTTP handler. In this case, Axios will pass this object along to
Node.js when it is provided.
Fixes: https://github.com/cloudevents/sdk-javascript/issues/48
Signed-off-by: Lance Ball <lball@redhat.com>