-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroutes.js
47 lines (41 loc) · 1.39 KB
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var express = require('express'),
DB = require('mongodb').Db,
router = express.Router(),
Server = require('mongodb').Server,
mongojs = require('mongojs'),
_ = require('underscore'),
exec = require('child_process').exec;
var DBServer = new Server('localhost', 27017);
/* GET home page. */
router.get('/', function(req, res) {
res.render('index');
});
router.get('/spaghetti', function(req, res) {
res.render('spaghetti');
});
router.get('/stream', function(req, res) {
res.render('stream');
});
router.get('/list-collections', function (req, res) {
// TODO: If we use more than one database, we need to pass this in the request
var databaseName = 'sydneysiege';
var db = new DB(databaseName, DBServer);
db.open(function(err, db) {
db.collection('rumors').find({}).toArray(function (err, docs) {
res.send(JSON.stringify(docs));
});
});
});
// TODO: For the front end bound trimming feature
// router.post('/trim-collection', function(req, res) {
// // TODO: these should all be passed in the POST body
// var collectionName = 'lakemba'
// databaseName = 'sydneysiege',
// minBound = '0',
// maxBound = '1418613549962';
// var cliArgs = databaseName + " " + collectionName + " " + minBound + " " + maxBound;
// exec('./data-collection/process-collections-cli.js' + cliArgs, function () {
// res.send("done");
// });
// });
module.exports = router;