diff --git a/swarmlab-app/src/run/app.js b/swarmlab-app/src/run/app.js index aa41013..0a53044 100755 --- a/swarmlab-app/src/run/app.js +++ b/swarmlab-app/src/run/app.js @@ -284,6 +284,57 @@ global.pipelines=[]; // rest get // *************************************************** +app.get('/get_log', [ + //check('access_token').isLength({ min: 40 }), + //check('llo').isBase64() + ], +cors(corsOptions), (req, res, next) => { + + (async() => { +/* +var mongourl = "mongodb://"+CONFIG.mongo.user+":"+CONFIG.mongo.password+"@ondemand_playground_mongo1:27017,ondemand_playground_mongo2:27017,ondemand_playground_mongo3:27017,ondemand_playground_mongo4:27017,ondemand_playground_mongo5:27017,ondemand_playground_mongo6:27017,ondemand_playground_mongo7:27017/fluent?replicaSet=rs1&authSource=swarmlabplaygroundstats" +const OPTS = { + useNewUrlParser: true, + useUnifiedTopology: true +}; +MongoClient.connect(mongourl, OPTS, function(err, client){ + if(err){ + console.log(err); + } else { + const db = client.db('fluent'); + //db.collection('log', onCollection); + console.log(JSON.stringify('mongo connected')) + var stream = db.collection('logs').find({}, { + tailable: true, + awaitdata: true +}).stream(); + +stream.on('data', function (doc) { + console.log(JSON.stringify(doc)) + //socket.write(JSON.stringify({'action': 'log','param': doc.log})); +}); + } +}); +*/ + var RES = new Object(); + RES.token = req.query["token"] + RES.start = req.query["start"] + RES.end = req.query["end"] + RES.filter = req.query["filter"] + var isvalid = await checkToken(RES.token); + if(isvalid.action == 'ok'){ + console.log("Authserver ok " + RES.token); + RES.error = true + }else{ + console.log("Authserver no " + RES.token); + RES.error = false + } + RES.error_msg = "ok" + res.json(RES) + })() + +}); + app.get('/run', [ //check('access_token').isLength({ min: 40 }), //check('llo').isBase64()