-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.coffee
66 lines (52 loc) · 1.65 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
http = require('http')
less = require('less')
path = require('path')
util = require('util')
nconf = require('nconf')
express = require('express')
mongoose = require('mongoose')
passport = require('passport')
MongoStore = require('connect-mongo')(express)
connectAssets = require('connect-assets')
nconf.argv()
.env()
.file({file: 'config/config.json'})
nconf.defaults
'NODE_ENV': 'development'
nconf.getByEnv = (key) ->
nconf.get(nconf.get('NODE_ENV') + ':' + key)
app = express()
app.set 'port', nconf.getByEnv('http:port')
app.set 'views', path.join(__dirname, 'app', 'views')
app.set 'view engine', 'jade'
app.set 'db-uri', nconf.getByEnv('db:uri')
app.use express.favicon()
app.use express.logger('dev')
app.use express.bodyParser()
app.use express.methodOverride()
app.use express.cookieParser()
mongoose.connect(app.get('db-uri'))
app.use express.session
secret: 'secret'
cookie:
maxAge: 7 * 24 * 60 * 60 * 1000
store: new MongoStore
mongoose_connection: mongoose.connections[0]
app.use require('./app/helpers')
app.use passport.initialize()
app.use passport.session()
app.use app.router
app.use connectAssets
src: path.join(__dirname, 'app', 'assets')
dest: path.join(__dirname, 'public')
app.use express.static(path.join(__dirname, "public"))
app.configure 'development', ->
app.use express.errorHandler()
models = require('./app/models')
models.defineModels()
require('./config/passport').registerStrategies()
require('./config/routes').registerRoutes(app)
server = http.createServer(app)
server.listen app.get('port'), ->
console.log 'Express server listening on port ' + app.get('port')
require('./config/socketio')(server)