-
Notifications
You must be signed in to change notification settings - Fork 19
/
app.js
35 lines (28 loc) · 894 Bytes
/
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
var fs = require('fs');
var express = require('express');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var path = require('path');
var bodyParser = require('body-parser');
var errorhandler = require('errorhandler');
var requirejs = require('requirejs');
requirejs.config({
baseUrl: './app',
name: 'main'
});
requirejs(['app/main.js'], function(Conway) {
var environment = process.env.NODE_ENV || 'development';
// General configuration
app.set('port', process.env.PORT || 3000);
// Development
if (environment === 'development') {
app.use(errorhandler());
app.use(express.static(path.join(__dirname, 'public')));
}
http.listen(app.get('port'), function() {
console.log('Conway started: ' + app.get('port') + ' (' + environment + ')');
});
app.use(bodyParser());
var conway = new Conway(fs, io);
});