Browse Source

test

master
lefteris 4 years ago
parent
commit
08b61b77ba
  1. 39
      swarmlab-app/src/run/app.js

39
swarmlab-app/src/run/app.js

@ -118,7 +118,44 @@ app.get("/test", cors(corsOptions), (req, res) => {
jsonfinal.push(JSON.parse(value.log)); jsonfinal.push(JSON.parse(value.log));
} }
}); });
res.send(jsonfinal); res.json(jsonfinal);
db.close();
});
});
});
app.get("/test2", cors(corsOptions), (req, res) => {
var RES = new Object();
const page = req.query["page"];
const per_page = req.query["per_page"];
var sort = req.query["sort"];
var filter = req.query["filter"];
var type = req.query["type"];
var sort = req.query["sort"];
var sorttmp1 = sort.split("|");
var sortname = sorttmp1[0];
var sortorder = sorttmp1[1];
console.error("Sort: " + sort + "\n Type: " + type);
var url = "mongodb://mongo:27017/";
MongoClient.connect(url, function (err, db) {
if (err) throw err;
var dbo = db.db("fluentdb");
dbo
.collection("test")
.find({})
.toArray(function (err, result) {
if (err) throw err;
// EPIDI EXW NESTED JSON PREPEI NA TO KANW PARSE DUO FORES
var obj = JSON.parse(JSON.stringify(result));
var jsonfinal = [];
obj.forEach((value) => {
if (value.log.includes("app_name")) {
jsonfinal.push(JSON.parse(value.log));
}
});
res.json(jsonfinal);
db.close(); db.close();
}); });
}); });

Loading…
Cancel
Save