Handling Requests multimessage
This commit is contained in:
@@ -27,23 +27,27 @@ const server = micro(async (req, res) => {
|
||||
const js = await json(req);
|
||||
|
||||
try {
|
||||
inputLine = JSON.parse(js);
|
||||
allInputLines = JSON.parse(js);
|
||||
send(res, 200, "OK");
|
||||
} catch (ex) {
|
||||
logger.log("error", "Input not in JSON format:" + line);
|
||||
logger.log("error", "Input not in JSON format:" + js);
|
||||
send(res, 401, "Input not in JSON Format");
|
||||
}
|
||||
|
||||
let isWhiteListed = ruleEngine.processData(inputLine);
|
||||
let miniInput = jsonminify(JSON.stringify(inputLine));
|
||||
let now = Date();
|
||||
if (isWhiteListed) {
|
||||
logger.log("debug", "Not Whitelisted: " + miniInput);
|
||||
fs.appendFileSync("./log/skipped.log", miniInput + "\n");
|
||||
} else {
|
||||
logger.log("info", "Not Whitelisted: " + miniInput);
|
||||
fs.appendFileSync("./log/issues.log", miniInput + "\n");
|
||||
for(i=0;i<allInputLines.length;i++){
|
||||
let theInputLine=allInputLines[i];
|
||||
let isWhiteListed = ruleEngine.processData(theInputLine);
|
||||
let miniInput = jsonminify(JSON.stringify(theInputLine));
|
||||
let now = Date();
|
||||
if (isWhiteListed) {
|
||||
logger.log("debug", "Not Whitelisted: " + miniInput);
|
||||
fs.appendFileSync("./log/skipped.log", miniInput + "\n");
|
||||
} else {
|
||||
logger.log("info", "Not Whitelisted: " + miniInput);
|
||||
fs.appendFileSync("./log/issues.log", miniInput + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
send(res, 200, "OK");
|
||||
});
|
||||
|
||||
server.listen(2222);
|
||||
Reference in New Issue
Block a user