forked from gijs/dashku
-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
76 lines (42 loc) · 1.55 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
'use strict';
// Dependencies
//
var connectRoute = require('connect-route');
var http = require('http');
var ss = require('socketstream');
require('./server/internals');
// Define a single-page client
ss.client.define('main', {
view : 'app.jade',
css : ['libs', 'app.styl'],
code : ['libs', 'app'],
tmpl : '*'
});
var api = require(__dirname + '/server/api');
ss.http.middleware.prepend(ss.http.connect.bodyParser());
ss.http.middleware.prepend(ss.http.connect.query());
ss.http.middleware.prepend(connectRoute(api));
// 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);
});