01-settings.js
1.0 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
// # settings
var compress = require('compression');
var IoC = require('electrolyte');
var https = require('https');
var http = require('http');
exports = module.exports = function (settings) {
var app = this;
// 设置环境变量
app.set('env', settings.server.env);
//设置默认的试图目录
app.set('views', settings.server.dir);
//设置默认的试图引擎
app.set('view engine', settings.server.engine);
if (settings.server.env === 'development') {
//开发模式下视图美化输出
app.locals.pretty = true;
}
if (settings.server.env === 'production') {
//启动视图缓存
app.enable('view cache');
//默认gzip压缩返回数据
// this overwrites res.write and res.end functions
app.use(compress());
}
if (settings.server.ssl.enabled) {
this.server = https.createServer(settings.server.ssl.options, this);
} else {
this.server = http.createServer(this);
}
};
exports['@require'] = ['igloo/settings'];