From 8c33d74f250c910b3deda2e498b11ade5645c580 Mon Sep 17 00:00:00 2001 From: "Shih-Yuan Lee (FourDollars)" Date: Tue, 23 Jul 2024 09:06:10 +0800 Subject: [PATCH] feat: include raw data in delivery payload (#55) 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() }