Skip to content

Commit

Permalink
read batch from data instead of env
Browse files Browse the repository at this point in the history
  • Loading branch information
birm authored Jan 6, 2023
1 parent d5e91d0 commit a0749a4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions handlers/fileHandlers.js
Original file line number Diff line number Diff line change
@@ -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));
};
};
Expand Down

0 comments on commit a0749a4

Please sign in to comment.