diff options
| author | Jules Laplace <jules@okfoc.us> | 2012-09-24 16:22:07 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2012-09-24 16:22:07 -0400 |
| commit | 686106d544ecc3b6ffd4db2b665d3bc879a58d8c (patch) | |
| tree | a5b5e50237cef70e12f0745371896e96f5f6d578 /app.js | |
ok
Diffstat (limited to 'app.js')
| -rw-r--r-- | app.js | 62 |
1 files changed, 62 insertions, 0 deletions
@@ -0,0 +1,62 @@ + +var express = require('express'), + io = require('socket.io'), + ejs = require('ejs'), + mongoose = require('mongoose'); + +var app = module.exports = express.createServer(); +io = require('socket.io').listen(app); + +app.configure(function(){ + app.set('views', __dirname + '/views'); + app.set('view engine', 'ejs'); + app.use(express.bodyParser()); + app.use(express.logger()); + app.use(express.methodOverride()); + app.use(express.static(__dirname + '/public')); +}); + +app.configure('development', function(){ + mongoose.connect('mongodb://localhost/warpfx'); + app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); + io.set('transports', ['websocket']); +}); + +app.configure('production', function(){ + io.enable('browser client minification'); // send minified client + io.enable('browser client etag'); // apply etag caching logic based on version number + io.enable('browser client gzip'); // gzip the file + io.set('log level', 1); // reduce logging + io.set('transports', [ // enable all transports (optional if you want flashsocket) + 'websocket' + , 'flashsocket' + , 'htmlfile' + , 'xhr-polling' + , 'jsonp-polling' + ]); +}); + + +/* + * Application routes. + * + */ + +var db = require( './lib/models' ), + room = require( './lib/room' ); + +app.get( '/', function( req, res ) { + res.render( 'grid', {} ); +}); +app.get( '/grid', function( req, res ) { + res.render( 'grid', {} ); +}); + +io.sockets.on('connection', function(socket){ + room.connect(io, socket); +}); + +app.listen(1783, function(){ + console.log("WARPFX server listening on port %d in %s mode", app.address().port, app.settings.env); +}); + |
