01-settings.js
1016 Bytes
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
// # settings
var compress = require('compression');
var https = require('https');
var http = require('http');
exports = module.exports = function(IoC, settings) {
var app = this;
// set the environment
app.set('env', settings.server.env);
// set the default views directory
// app.set('views', settings.views.dir);
// set the default view engine
// app.set('view engine', settings.views.engine);
if (settings.server.env === 'development') {
// make view engine output pretty
app.locals.pretty = true;
}
if (settings.server.env === 'production') {
// enable view caching
// app.enable('view cache');
// compress response data with gzip/deflate
// 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'] = [ '$container', 'igloo/settings' ];