-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.coffee
35 lines (27 loc) · 1.11 KB
/
app.coffee
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
http = require 'http'
global.ss = require 'socketstream'
global.config = require './server/config.coffee'
db = require './server/db.coffee'
# Controllers, a way of sharing common logic between RPC and REST APIs
global.userController = require "#{__dirname}/server/controllers/user.coffee"
global.projectController = require "#{__dirname}/server/controllers/project.coffee"
# Define a single-page client
ss.client.define 'main',
view: 'app.jade'
css: ['libs', 'app.styl']
code: ['libs', 'app']
tmpl: '*'
# Serve this client on the root URL
ss.http.route '/', (req, res) ->
res.serveClient 'main'
# Code Formatters
ss.client.formatters.add require library for library in ['ss-coffee', 'ss-jade', '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
ss.client.packAssets() if ss.env is 'production'
# Start web server
server = http.Server ss.http.middleware
server.listen config[ss.env].port
# Start SocketStream
ss.start server