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>
This commit is contained in:
parent
719c2f01e4
commit
d8df5efa94
|
@ -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);
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue