index.js
1.5 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
// # config
var _ = require('underscore')
var path = require('path')
var maxAge = 24 * 60 * 60 * 1000
var config = module.exports = {}
var env = 'development'
var rootDir = path.join(__dirname, '..')
var environments = {
development: {
port: 3000,
host: 'localhost',
db: {
host: 'localhost',
dbname: 'mydb',
port: '27017',
opts: {}
},
redis: {
host: 'localhost',
port: 6379,
prefix: 'TODO',
maxAge: maxAge
},
cookieParser: 'TODO',
session: {
secret: 'TODO',
key: 'TODO',
cookie: {
maxAge: maxAge
}
},
publicDir: path.join(rootDir, 'assets', 'public'),
lessMiddleware: {
src: path.join(rootDir, 'assets', 'public'),
force: true
}
},
production: {
port: 80,
host: '',
db: {},
redis: {},
cookieParser: '',
session: {},
publicDir: path.join(rootDir, 'assets', 'dist')
}
}
if (_.isString(process.env.NODE_ENV) && _.contains(_.keys(environments), env))
env = process.env.NODE_ENV
_.defaults(config, {
staticServer: {
maxAge: maxAge,
},
ssl: false,
env: env,
rootDir: rootDir,
viewsDir: path.join(rootDir, 'app', 'views'),
})
_.extend(config, environments[config.env])
config.protocol = (config.ssl) ? 'https' : 'http'
config.favicon = path.join(config.publicDir, 'favicon.ico')
config.winstonMongoDB = _.extend(config.db, {
// don't perform second req to verify
safe: false,
port: parseInt(config.db.port, 10)
})