-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
43 lines (35 loc) · 1.07 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
var xmpp = require('jacasr')
, express = require('express')
, app = express()
, fs = require('fs')
, path = require('path')
, vm = require('vm');
try {
app.configure('development', function(){
app.use(express.static(__dirname + '/public'));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function(){
var oneYear = 31557600000;
app.use(express.static(__dirname + '/public', { maxAge: oneYear }));
app.use(express.errorHandler());
});
app.use(express.logger());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
global.app = app;
var dir = 'webserver_plugins';
fs.readdirSync(path.join(__dirname, dir)).forEach(function(file){
if (/\.js$/.exec(file) === false) {
return;
}
require('./' + path.join(dir, file));
console.log('[ load ] ' + path.join(dir, file));
});
app.listen(process.env['app_port'] || 3000);
console.log('server started in ' + app.get('env') + ' mode');
}
catch (e) {
console.error(e);
}