-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
61 lines (49 loc) · 1.59 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
/**
* Canvas Model Design
*
*/
var express = require('express')
, http = require('http')
, path = require('path')
, fs = require('fs')
, ratchet = require('ratchetio');
var app = express()
, server = http.createServer(app)
, io = require('socket.io').listen(server);
app.configure(function(){
var MemoryStore = require('connect').session.MemoryStore;
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('th4c00k13p4s3r'));
app.use(express.session({ store: new MemoryStore({ reapInterval: 60000 * 10 }) }));
app.use(app.router);
ratchet.handleUncaughtExceptions("969336c0071448bf9892a855ea0d0843");
app.use(ratchet.errorHandler("969336c0071448bf9892a855ea0d0843"));
app.use(require('less-middleware')({ src: __dirname + '/public' }));
app.use(express.static(path.join(__dirname, 'public')));
});
app.configure('development', function(){
app.use(express.errorHandler());
});
// Load Config
require('./config/config');
// Database
require('./config/db');
// Load Models
var modelPath = __dirname + '/models'
, models = fs.readdirSync(modelPath);
models.forEach(function(file) {
require(modelPath + '/' + file);
});
// Load Routes
require('./config/routes')(app);
// Load Socket Server
require('./utils/sockets')(io);
server.listen(app.get('port'), function(){
console.log("Canvas Model Design server listening on port " + app.get('port'));
});