-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathapp.js
More file actions
38 lines (26 loc) · 781 Bytes
/
Copy pathapp.js
File metadata and controls
38 lines (26 loc) · 781 Bytes
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
var express = require('express')
, app = express()
, http = require('http')
, server = http.createServer(app)
, routes = require('./routes')
, socket = require('./routes/socket.js')
, io = require('socket.io').listen(server);
// Heroku config only
if(process.env.PORT) {
io.configure(function () {
io.set("transports", ["xhr-polling"]);
io.set("polling duration", 10);
});
}
// Configuration
var config = require('./config')(app, express);
// Routes
app.get('/', routes.index);
app.get('/partials/:name', routes.partials);
// redirect all others to the index (HTML5 history)
app.get('*', routes.index);
// Socket.io Communication
io.sockets.on('connection', socket);
// Start server
var port = process.env.PORT || 5000;
server.listen(port);