-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.coffee
More file actions
29 lines (23 loc) · 915 Bytes
/
app.coffee
File metadata and controls
29 lines (23 loc) · 915 Bytes
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
express = require 'express'
{config} = require './config'
exports.startServer = (port, path, callback) ->
app = express express.logger()
port = parseInt(process.env.PORT or port, 10)
# Express init
app.configure ->
app.use express.bodyParser()
app.use express.methodOverride()
app.use express.errorHandler
dumpExceptions: true
showStack: true
# Serve our static assets
app.use express.static("#{__dirname}/#{path}")
# Since everything is client side, we only serve index.html
app.get "*", (req, res) ->
res.sendfile "#{__dirname}/#{path}/index.html"
# Serve it up!
app.listen port, ->
console.info "Listening on #{port}, dawg"
app
# We only start this up if we're not using brunch to run it. Pretty hacky, I know.
exports.startServer config.server.port, config.paths.public unless config.server.run?