forked from LutherSrProject/TapVote
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
64 lines (53 loc) · 2.14 KB
/
index.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
//Attach global variables
require('./modules/globals');
/**
* Module dependencies.
*/
var express = require('express');
var cors = require('cors');
var vote = require('./routes/vote');
var deVote = require('./routes/deVote');
var getSurveyResults = require('./routes/getSurveyResults');
var getSurveyInfo = require('./routes/getSurveyInfo');
var createSurvey = require('./routes/createSurvey');
var addQuestions = require('./routes/addQuestions');
var removeQuestion = require('./routes/removeQuestion');
var addAnswer = require('./routes/addAnswer');
var removeAnswer = require('./routes/removeAnswer');
var http = require('http');
var path = require('path');
var app = express();
// all environments
app.set('port', process.env.PORT || 8000);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.favicon());
app.use(express.json()); //express's json request body parser
app.use(express.urlencoded()); //in the off chance that we use urlencoded requests
//notably, leaving out file upload support for now
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.session());
// artificially add a second of latency to every request :)
// app.use(function(req,res,next){setTimeout(next,1000)});
app.use(cors());
app.use(app.router);
app.use(require('stylus').middleware(__dirname + '/www'));
app.use(express.static(path.join(__dirname, 'www')));
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
app.post('/vote', vote.vote());
app.post('/deVote', deVote.deVote());
app.post('/createSurvey', createSurvey.createSurvey());
app.post('/addQuestions', addQuestions.addQuestions());
app.post('/removeQuestion', removeQuestion.removeQuestion());
app.post('/addAnswer', addAnswer.addAnswer());
app.post('/removeAnswer', removeAnswer.removeAnswer());
app.get('/getSurveyResults', getSurveyResults.getSurveyResults());
app.get('/getSurveyInfo', getSurveyInfo.getSurveyInfo());
http.createServer(app).listen(app.get('port'), function() {
logger.info('Express server listening on port ' + app.get('port'));
});
exports.logger = logger; // export the Winston logger