-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
69 lines (55 loc) · 1.74 KB
/
app.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* Module dependencies.
*/
var express = require('express');
var faye = require('faye');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');
var expressValidator = require('express-validator');
//db vars
var mongo = require('mongodb');
var monk = require('monk');
var db = monk('mongodb://Admin:[email protected]:10078/timder');
//faye server vars
var bayeux = new faye.NodeAdapter({
mount: '/faye',
timeout: 45
});
var app = express();
var server = http.createServer(app);
bayeux.attach(server);
// all environments
app.use(express.favicon('favicon.ico'));
app.use(express.static(__dirname + '/public'));
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(expressValidator());
app.use(express.methodOverride());
app.use(app.router);
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
//getpages
app.get('/', routes.index);
app.get('/users', user.list);
app.get('/userlist', routes.userlist(db));
app.get('/scoreboard', routes.scoreboard(db));
app.get('/newuser', routes.newuser);
app.get('/admin', routes.admin(db));
//postpages
app.post('/newuser', routes.adduser(db));
app.post('/removeuser', routes.removeuser(db));
app.post('/removevote', routes.removevote(db));
app.post('/cleardb', routes.cleardb(db));
app.post('/insertvotes', routes.insertvotes(db));
app.post('/setcompanyuser', routes.setcompanyuser(db));
app.post('/resetcompanyuser', routes.resetcompanyuser);
server.listen(process.env.PORT || 3000);
console.log("Server up and listening on port 3000")