forked from gijs/dashku
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
95 lines (58 loc) · 2 KB
/
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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
'use strict';
// Dependencies
//
var bodyParser = require('body-parser');
var connectRoute = require('connect-route');
var http = require('http');
var ss = require('socketstream');
require('./server/internals');
// Declare order of dependencies to load
//
var codeLibDependencies = [
'libs/codemirror.js',
'libs/coffee-script.js',
'libs/codemirror-compressed.js',
'libs/head.min.js',
'libs/jquery.min.js',
'libs/jquery.ui-1.8.20.custom.min.js',
'libs/underscore.min.js',
'libs/bootstrap.min.js',
'libs/highlight.pack.js',
'app'
];
// Define a single-page client
ss.client.define('main', {
view : 'app.jade',
css : ['libs', 'app.styl'],
code : codeLibDependencies,
tmpl : '*'
});
var api = require(__dirname + '/server/api');
ss.http.middleware.prepend(bodyParser.json());
ss.http.middleware.prepend(require('./server/queryMiddleware')());
ss.http.middleware.prepend(connectRoute(api));
ss.session.options.secret = ss.api.app.config.sessionSecret;
// Serve this client on the root URL
ss.http.route('/', function (req, res) {
res.serveClient('main');
});
// Use redis for session store
ss.session.store.use('redis', ss.api.app.config.redis);
// Use redis for pubsub
ss.publish.transport.use('redis', ss.api.app.config.redis);
// Code Formatters
ss.client.formatters.add(require('ss-coffee'));
ss.client.formatters.add(require('ss-jade'));
ss.client.formatters.add(require('ss-stylus'));
// Use server-side compiled Hogan (Mustache) templates. Other engines available
ss.client.templateEngine.use(require('ss-hogan'));
// Minimize and pack assets if you type: SS_PACK=1 SS_ENV=production node app.js
if (ss.env === 'production') { ss.client.packAssets(ss.api.app.config.packAssets); }
// Start SocketStream
var server = http.Server(ss.http.middleware);
server.listen(ss.api.app.config.port);
ss.start(server);
// So that the process never dies
process.on('uncaughtException', function (err) {
console.error('Exception caught: ', err);
});