Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ You can choose almost any popular web framework for port binding. Use an
binary and structured events in either the 1.0 or 0.3 protocol formats.

```js
const {
CloudEvent,
Receiver
} = require("cloudevents");
const app = require("express")();
const {Receiver} = require("cloudevents");

// body and headers come from an incoming HTTP request, e.g. express.js
const receivedEvent = Receiver.accept(req.headers, req.body);
console.log(receivedEvent);
app.post("/", (req, res) => {
// body and headers come from an incoming HTTP request, e.g. express.js
const receivedEvent = Receiver.accept(req.headers, req.body);
console.log(receivedEvent);
});
```

#### Emitting Events
Expand Down
7 changes: 3 additions & 4 deletions examples/express-ex/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint-disable no-console */

const express = require("express");
const { Receiver } = require("cloudevents");
const {Receiver} = require("cloudevents");

const app = express();
const receiver = new Receiver();

app.use((req, res, next) => {
let data = "";
Expand All @@ -20,7 +19,7 @@ app.use((req, res, next) => {
});
});

app.post("/", function (req, res) {
app.post("/", (req, res) => {
console.log("HEADERS", req.headers);
console.log("BODY", req.body);

Expand All @@ -34,6 +33,6 @@ app.post("/", function (req, res) {
}
});

app.listen(3000, function () {
app.listen(3000, () => {
console.log("Example app listening on port 3000!");
});