-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
128 lines (100 loc) · 2.43 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//NOTES:
// Things we need to track
// #VFAparty
// #DetroitHustlesHarder
/**
*
* External Module dependencies.
*
*/
var express = require('express');
var http = require('http');
var path = require('path');
var colors = require('colors')
var socketIO = require('socket.io')
//var ImmortalNTwitter = require('immortal-ntwitter');
//Globals
var socket, io, server;
/**
*
* Custom Modules
*
*/
var Database = require('./modules/DBConnection')
var Twitter = require('./modules/Twitter')
var Instagram = require('./modules/Instagram')
var Twitter = require('./modules/Twitter')
/**
*
* Setup Custom Modules
*
*/
Database.MongoConnect()
/**
*
* Application Routes.
*
*/
var routes = {}
routes.main = require('./routes/index-route');
routes.instagram = require('./routes/instagram-route')
/**
*
* Express Application Config
*
*/
var app = express();
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use( require('less-middleware')(path.join( __dirname + '/public' ) ));
app.use(express.static(path.join(__dirname, 'public')));
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
/**
*
* Boot Server, Socket.IO and Twitter Stream
*
*/
server = http.createServer(app)
io = socketIO.listen(server)
io.configure(function () {
io.set("transports", ['websocket', 'xhr-polling']);
io.set('log level', 1);
//io.set("polling duration", 10);
});
server.listen(app.get('port'), function(){
console.log(' Express server listening on port '.inverse +' '+ app.get('port').toString().magenta);
});
io.sockets.on('connection', function(socket){
console.log('new socket connection')
})
Twitter.run(io)
/**
*
* Application Routes
*
*/
app.get('/', routes.main.index);
app.get('/setup',routes.main.setup)
app.get('/visualizer', routes.main.visualizer)
//for testing posts
app.post('/setup',function(req,res){
console.log(req.body)
res.send('')
})
app.get('/instagram', routes.instagram.create )
app.post('/instagram', routes.instagram.consume(Database, Instagram, io) )
app.post('/instagram/new',routes.instagram.new(Instagram))
app.delete('/instagram',routes.instagram.delete(Instagram) )
app.get('/test', function(req,res){
res.render('test-view',{})
})