-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.coffee
41 lines (30 loc) · 1.18 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'
path = require 'path'
_ = require 'underscore'
#Watcher = require('./util/watcher').watcher
Settings = require 'settings'
templates = {}
settings = new Settings(path.join __dirname, 'config/environment.js').getEnvironment()
#watcher = new Watcher settings.watcherOptions, templates
fs = require 'fs'
indexFilePath = 'templates/index.html'
#watcher.compileTemplates()
compileTemplate = (file) ->
templateName = path.basename file, path.extname(file)
fs.readFile file, 'utf8', (err, data) =>
return console.log(err) if err
compiled = _.template data
templates[templateName] = compiled
compileTemplate indexFilePath
app = express.createServer()
app.configure ->
app.use express.errorHandler settings.errorHandling
app.use express.static settings.publicDir, maxAge: settings.staticMaxAge
app.use express.bodyParser()
app.use express.cookieParser maxAge: settings.cookieMaxAge
app.use express.session secret: settings.cookieSecret
#app.configure 'development', ->
# watcher.watch()
app.get '/', (req, res) ->
res.send templates['index']({name: 'World'})
app.listen process.env.PORT || 8001