|
|
@ -2,6 +2,7 @@ var path = require('path'); |
|
|
|
var app = require('express')(); |
|
|
|
var http = require('http').Server(app); |
|
|
|
var io = require('socket.io')(http); |
|
|
|
vat MongoClient = require('mongodb').MongoClient; |
|
|
|
|
|
|
|
//const socketAuth = require('socketio-auth');
|
|
|
|
|
|
|
@ -63,7 +64,45 @@ cors(corsOptions), (req, res, next) => { |
|
|
|
res.json(RES) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------
|
|
|
|
var mongouser = "playgrounduser"; |
|
|
|
var mongopass = "efvvnuioervefSDFSGYGHRDFVsdfergvssppiiedifhwincvinviw_dbfjbsifbsdkjfswuunscfudfgbbfvibqefwrvnine"; |
|
|
|
const mongourl = 'mongodb://'+mongouser+':'+mongopass+'@node1:27017,node2:27017/?replicaSet=rs0'; |
|
|
|
const dbNameedit = 'swarmlab_playground_logs'; |
|
|
|
var dbName; |
|
|
|
// Initialize connection once
|
|
|
|
MongoClient.connect(mongourl, function(err, database) { |
|
|
|
if(err) throw err; |
|
|
|
//dbName = database;
|
|
|
|
dbName = dayabase.db('swarmlab_playground_logs'); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
dbName.collection("devel_log").find({}, function(err, docs) { |
|
|
|
|
|
|
|
docs.each(function(err, doc) { |
|
|
|
if(doc) { |
|
|
|
console.log(doc); |
|
|
|
} |
|
|
|
else { |
|
|
|
res.end(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
/* |
|
|
|
MongoClient.connect(mongourl, options).then((client) => { |
|
|
|
dbName = client.db('swarmlab_playground_logs'); |
|
|
|
// do database things
|
|
|
|
}).catch((error) => { |
|
|
|
// handle connection errors
|
|
|
|
}); |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
io.origins('*:*') // for latest version
|
|
|
|
|
|
|
|
io.on('connection', s => { |
|
|
|