From a0749a42bf5bc67d0f472145924607fbdbe71bc0 Mon Sep 17 00:00:00 2001 From: Ryan Birmingham Date: Fri, 6 Jan 2023 16:06:01 -0500 Subject: [PATCH] read batch from data instead of env --- handlers/fileHandlers.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/handlers/fileHandlers.js b/handlers/fileHandlers.js index ade6199..8e000bc 100644 --- a/handlers/fileHandlers.js +++ b/handlers/fileHandlers.js @@ -1,17 +1,17 @@ const fs = require('fs').promises; const uuid = require("uuid"); -var file_prefix = process.env.file_prefix; // write a file containing the request body function writeFile(path, prefix) { return function(req, res, next) { - if (file_prefix){ - prefix = file_prefix + "_" + prefix; - } - let fn = prefix + "_" + uuid.v4() + ".json"; + const json = JSON.parse(req.body); json.create_date = new Date(); req.body = JSON.stringify(json); + if (json.batch){ + prefix = json.batch + "_" + prefix; + } + let fn = prefix + "_" + uuid.v4() + ".json"; fs.writeFile(path + fn, req.body).then(()=>next()).catch((e) => next(e)); }; };