From 883655717f46052eb390bd2faba7dbb3057eb5bd Mon Sep 17 00:00:00 2001 From: Jane Petrovna Date: Sun, 6 Jun 2021 02:10:39 -0400 Subject: [PATCH] i am dying on an immeasureable number of levels --- index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index a70855a..5b44ab3 100644 --- a/index.js +++ b/index.js @@ -20,6 +20,17 @@ if (log_disabled) { app.use("/files", express.static("projects")); +app.use(function myMiddleware(req, res, next) { + req.rawBody = ''; + + req.on('data', function (chunk) { + req.rawBody += chunk; + }); + + // call next() outside of 'end' after setting 'data' handler + next(); +}); + function get_indexes(project_id) { if (cache[project_id]) { let indexes = ""; @@ -114,8 +125,8 @@ function diff(current, checked) { app.post("/updates/:project(\\w+)", (req, res) => { let project_id = req.params['project']; - const body = req.body || ""; - console.log(req.body); + const body = req.rawBody || ""; + console.log(req.rawBody); console.log(`${req.body}, ${typeof req.body}`); console.log(`${body}`); let adjustedBody = body.replace(/\r/, "");