-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.coffee
executable file
·41 lines (31 loc) · 1.32 KB
/
server.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
36
37
38
39
40
41
express = require 'express'
compression = require 'compression'
require 'jade'
_ = require 'underscore'
appBaseUrl = ''
app = express()
app.set 'view engine', 'jade'
app.use compression()
if process.env.NODE_ENV isnt 'production'
webpackDevMiddleware = require 'webpack-dev-middleware'
webpack = require 'webpack'
middlewareOptions =
stats:
colors: true
noInfo: true # Comment this out for more verbose webpack information
app.use webpackDevMiddleware(webpack(require './webpack.dev.config'), middlewareOptions)
lessMiddleware = require 'less-middleware'
app.use "/styles", lessMiddleware('./public/styles')
app.use "/styles", express.static('./public/styles')
app.use "/scripts", express.static('./public/scripts')
app.use "/favicon.ico", express.static('./public/favicon.ico')
app.use '/api', require './api'
app.get '/*', (req, res) ->
# template is not actually needed because we're not doing server-side rendering... you could pre-render
# the template and send a string or just use a static page in coffeescript
res.render 'page', {appBaseUrl, title: 'org-explorer'}
port = parseInt (process.env.PORT or 3099), 10
server = app.listen port, ->
address = server.address()
url = "http://#{address.host or 'localhost'}:#{port}"
console.info "Listening at #{url}"