|
c1b2f76
Jonathan Mumm authored
|
||
| 1 | var express = require('express'); | |
| 2 | ||
| 3 | var app = module.exports = express.createServer(); | |
| 4 | ||
|
06e5c25
Jonathan Mumm authored
|
||
| 5 | var port = 3000; | |
| 6 | if (process.env.NODE_ENV === "production") { | |
| 7 | port = 80; | |
| 8 | } | |
|
b7ab920
Jonathan Mumm authored
|
||
| 9 | ||
|
c1b2f76
Jonathan Mumm authored
|
||
| 10 | // Configuration | |
|
911471a
Jonathan Mumm authored
|
||
| 11 | app.configure(function() { | |
|
c1b2f76
Jonathan Mumm authored
|
||
| 12 | app.set('views', __dirname + '/views'); | |
| 13 | app.set('view engine', 'jade'); | |
| 14 | app.use(express.bodyParser()); | |
| 15 | app.use(express.methodOverride()); | |
| 16 | app.use(app.router); | |
| 17 | app.use(express.static(__dirname + '/public')); | |
| 18 | }); | |
| 19 | ||
|
911471a
Jonathan Mumm authored
|
||
| 20 | app.configure('development', function() { | |
|
dc402c3
Jonathan Mumm authored
|
||
| 21 | app.use(express.errorHandler({ | |
| 22 | dumpExceptions: true, | |
| 23 | showStack: true | |
| 24 | })); | |
|
c1b2f76
Jonathan Mumm authored
|
||
| 25 | }); | |
| 26 | ||
|
43b8946
Jonathan Mumm authored
|
||
| 27 | app.configure('production', function() { | |
| 28 | app.use(express.errorHandler()); | |
| 29 | }); | |
| 30 | ||
|
911471a
Jonathan Mumm authored
|
||
| 31 | // Routes | |
| 32 | app.get('/', function(req, res) { | |
| 33 | res.render('index', { | |
|
06e5c25
Jonathan Mumm authored
|
||
| 34 | title: 'RouletteTok' | |
|
911471a
Jonathan Mumm authored
|
||
| 35 | }); | |
|
c1b2f76
Jonathan Mumm authored
|
||
| 36 | }); | |
| 37 | ||
| 38 | if (!module.parent) { | |
|
b7ab920
Jonathan Mumm authored
|
||
| 39 | app.listen(port); | |
| 40 | console.log("Server listening on port %d", port); | |
|
c1b2f76
Jonathan Mumm authored
|
||
| 41 | } | |
| 42 | ||
|
dc402c3
Jonathan Mumm authored
|
||
| 43 | // Start my Socket.io app and pass in the socket | |
|
2e25fc4
Jonathan Mumm authored
|
||
| 44 | var io = require('socket.io').listen(app); | |
|
8f600aa
jonmumm authored
|
||
| 45 | io.configure(function() { | |
| 46 | io.set('close timeout', 60*60*24); | |
| 47 | }); | |
| 48 | ||
|
2e25fc4
Jonathan Mumm authored
|
||
| 49 | require('./socketapp').start(io.sockets); |