Last active
May 11, 2024 11:21
-
-
Save MeiyappanKannappa/bee5a33e9f7fea403244392473a8e176 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const app = require("express")(); | |
| const { CloudEvent, HTTP } = require("cloudevents"); | |
| const bodyParser = require("body-parser"); | |
| // support parsing of application/json type post data | |
| app.use(bodyParser.json()); | |
| app.use(bodyParser.json({ type: "application/*+json" })); | |
| app.post("/", (req, res) => { | |
| console.log("HEADERS", req.headers); | |
| console.log("BODY", req.body); | |
| const receivedEvent = HTTP.toEvent({ headers: req.headers, body: req.body }); | |
| console.log(receivedEvent); | |
| }); | |
| app.listen(3000, () => { | |
| console.log("Example app listening on port 3000!"); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment