-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
44 lines (33 loc) · 992 Bytes
/
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
// My SocketStream 0.3 app
var http = require('http'),
ss = require('socketstream');
// Define a single-page client called 'main'
ss.client.define('main', {
view: 'app.html',
css: ['libs/reset.css', 'app.css'],
code: ['libs/jquery.min.js', 'app'],
tmpl: '*'
});
// Serve this client on the root URL
ss.http.route('/', function(req, res){
res.serveClient('main');
});
// Use server-side compiled Hogan (Mustache) templates. Others engines available
ss.client.templateEngine.use(require('ss-hogan'));
// Minimize and pack assets if you type: SS_ENV=production node app.js
if (ss.env === 'production') ss.client.packAssets();
var config = {
redis: {
host: 'localhost',
port: 6379,
db: 4
},
port: 3000
};
ss.session.store.use('redis', config.redis);
ss.publish.transport.use('redis', config.redis);
// Start web server
var server = http.Server(ss.http.middleware);
server.listen(process.env.PORT || config.port);
// Start SocketStream
ss.start(server);