From 47858bbd8cefbff54c7fa5e73a242781fadce754 Mon Sep 17 00:00:00 2001 From: "Shih-Yuan Lee (FourDollars)" Date: Sat, 6 Jun 2020 18:26:29 +0800 Subject: [PATCH] Make the payload include the raw data of the delivery body. (Closes #9) (Closes #5) --- lib/server.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/server.js b/lib/server.js index 4de3d23..d88457b 100644 --- a/lib/server.js +++ b/lib/server.js @@ -32,6 +32,17 @@ module.exports = (testRoute) => { app.use(require('express-sslify').HTTPS({ trustProtoHeader: true })) } + app.use((req, res, next) => { + var buf = '' + req.on('data', (chunk) => { + buf += chunk + }) + req.on('end', () => { + req.rawdata = buf + }) + next() + }) + app.use(cors()) app.use(express.json()) app.use(express.urlencoded({ extended: true })) @@ -100,6 +111,7 @@ module.exports = (testRoute) => { payload: { ...req.headers, body: req.body, + rawdata: req.rawdata, query: req.query, timestamp: Date.now() }