Skip to content

Commit

Permalink
chore(example): Replaced body parser with express JSON parser (#334)
Browse files Browse the repository at this point in the history
Signed-off-by: Philip Hayes <phayes@redhat.com>

Co-authored-by: Philip Hayes <phayes@redhat.com>
  • Loading branch information
2 people authored and lance committed Sep 11, 2020
1 parent 6732194 commit e6204af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
16 changes: 2 additions & 14 deletions examples/express-ex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,8 @@
const express = require("express");
const { Receiver } = require("cloudevents");
const app = express();

app.use((req, res, next) => {
let data = "";

req.setEncoding("utf8");
req.on("data", function (chunk) {
data += chunk;
});

req.on("end", function () {
req.body = data;
next();
});
});
const bodyParser = require('body-parser')
app.use(bodyParser.json())

app.post("/", (req, res) => {
console.log("HEADERS", req.headers);
Expand Down
1 change: 1 addition & 0 deletions examples/express-ex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"author": "fabiojose@gmail.com",
"license": "Apache-2.0",
"dependencies": {
"body-parser": "^1.19.0",
"cloudevents": "^3.1.0",
"express": "^4.17.1"
}
Expand Down

0 comments on commit e6204af

Please # to comment.