const micro = require('micro'); const { json, send } = require('micro'); const { RuleEngine } = require('./RuleEngine'); const fs = require('fs'); const jsonminify = require('jsonminify'); const winston = require("winston"); const logger = winston.createLogger({ level: 'info', format: winston.format.combine( winston.format.timestamp(), winston.format.printf(info => { return `${info.timestamp} ${info.level}: ${info.message}`; }) ), transports: [ new winston.transports.Console(), new winston.transports.File({ filename: './log/LogAggregatorError.log', level: 'error' }), new winston.transports.File({ filename: './log/Combined.log' }) ] }); const ruleEngine = new RuleEngine("*"); console.log(`logAggregator Service Copyright (C) 2019 j.tretter@gmail.com This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see .`); logger.log("info","logAggregator Service v0.1 Starting"); const server = micro(async (req, res) => { const js = await json(req); try { allInputLines = JSON.parse(js); } catch (ex) { logger.log("error", "Input not in JSON format:" + js); send(res, 401, "Input not in JSON Format"); } for(i=0;i