lib: expose constants in a more intuitive way (#299)

* Constants can now be accessed more easily from the top level import/require

users can now do `const { CONSTANTS } = require('cloudevents')`

fixes #298

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
This commit is contained in:
Lucas Holmquist 2020-08-04 09:42:28 -04:00 committed by GitHub
parent bc81242c7c
commit a7e0aa07ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -8,6 +8,8 @@ import { Receiver, Mode } from "./transport/receiver";
import { Protocol } from "./transport/protocols"; import { Protocol } from "./transport/protocols";
import { Headers, headersFor } from "./transport/http/headers"; import { Headers, headersFor } from "./transport/http/headers";
import CONSTANTS from "./constants";
export { export {
// From event // From event
CloudEvent, CloudEvent,
@ -25,4 +27,6 @@ export {
TransportOptions, TransportOptions,
Headers, Headers,
headersFor, headersFor,
// From Constants
CONSTANTS,
}; };

View File

@ -1,5 +1,5 @@
import { expect } from "chai"; import { expect } from "chai";
import CONSTANTS from "../../src/constants"; import { CONSTANTS } from "../../src";
describe("Constants exposed by top level exports", () => { describe("Constants exposed by top level exports", () => {
it("Exports an ENCODING_BASE64 constant", () => { it("Exports an ENCODING_BASE64 constant", () => {