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 express = require("express");
|
||||||
const { Receiver } = require("cloudevents");
|
const { Receiver } = require("cloudevents");
|
||||||
const app = express();
|
const app = express();
|
||||||
|
const bodyParser = require('body-parser')
|
||||||
app.use((req, res, next) => {
|
app.use(bodyParser.json())
|
||||||
let data = "";
|
|
||||||
|
|
||||||
req.setEncoding("utf8");
|
|
||||||
req.on("data", function (chunk) {
|
|
||||||
data += chunk;
|
|
||||||
});
|
|
||||||
|
|
||||||
req.on("end", function () {
|
|
||||||
req.body = data;
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
app.post("/", (req, res) => {
|
app.post("/", (req, res) => {
|
||||||
console.log("HEADERS", req.headers);
|
console.log("HEADERS", req.headers);
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
"author": "fabiojose@gmail.com",
|
"author": "fabiojose@gmail.com",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"body-parser": "^1.19.0",
|
||||||
"cloudevents": "^3.1.0",
|
"cloudevents": "^3.1.0",
|
||||||
"express": "^4.17.1"
|
"express": "^4.17.1"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue