-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathserver.js
76 lines (70 loc) · 1.81 KB
/
server.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
process.title = 'node-wargames';
process.addListener('uncaughtException', function (err, stack) {
console.log('Caught exception: ' + err);
console.log(err.stack.split('\n'));
});
var connect = require('connect');
var assetManager = require('connect-assetmanager');
var assetHandler = require('connect-assetmanager-handlers');
var express = require('express');
var assets = assetManager({
'js': {
'route': /\/static\/js\/[0-9]+\/.*\.js/
, 'path': './public/js/'
, 'dataType': 'js'
, 'files': [
'http://code.jquery.com/jquery-latest.js'
, 'http://cdn.socket.io/stable/socket.io.js'
, 'raphael.js'
, 'map.js'
, 'jquery.wargames.js'
]
, 'preManipulate': {
'^': [
function (file, path, index, isLast, callback) {
if (path.match(/jquery.wargames/)) {
callback(file.replace(/'#socketIoPort#'/, port));
} else {
callback(file);
}
}
]
}
}, 'css': {
'route': /\/static\/css\/[0-9]+\/.*\.css/
, 'path': './public/css/'
, 'dataType': 'css'
, 'files': [
'wargames.css'
]
}
});
var port = 5656;
var app = module.exports = express.createServer();
app.configure(function() {
app.set('view engine', 'ejs');
app.set('views', __dirname + '/views');
});
app.configure(function() {
app.use(connect.logger({ format: ':req[x-real-ip]\t:status\t:method\t:url\t' }));
app.use(assets);
app.use(connect.static(__dirname + '/public'));
});
app.dynamicHelpers({
'cacheTimeStamps': function(req, res) {
return assets.cacheTimestamps;
}
});
app.get(/.*/, function(req, res) {
res.render('layout');
});
app.listen(port, null);
var Wargames = require(__dirname+'/lib/wargames');
new Wargames(app, {
ircNetwork: 'irc.freenode.net'
, ircChannel: '#Node.js'
, ircBotNick: 'MrWarGames'
, ircUserName: 'MrWarGames'
, ircRealName: 'MrWarGames'
, cachePath: '/tmp/cache.json'
});