-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (29 loc) · 946 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
'use strict';
// 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.jade',
css: ['app.styl'],
code: ['libs/jquery.min.js', 'libs/davis.min.js', 'app'],
tmpl: '*'
});
// Serve this client on the root URL
ss.http.route('/', function(req, res){
res.serveClient('main');
});
// Code Formatters
ss.client.formatters.add(require('ss-jade'));
ss.client.formatters.add(require('ss-stylus'));
// 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();
}
// Start web server
var server = http.Server(ss.http.middleware);
server.listen(process.env.PORT || 3000);
// Start SocketStream
ss.start(server);