-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexpress-setup.js
More file actions
38 lines (29 loc) · 1014 Bytes
/
express-setup.js
File metadata and controls
38 lines (29 loc) · 1014 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
// modules > 3rd party
var _ = require('lodash');
var dust = require('dustjs-linkedin');
var server = require('express')();
/* prevent express from looking up the view in the file system
* since we are using dust.cache (dust.cache should be populated
* in load-templates.js).
*/
server.get('view').prototype.lookup = function(name) {
// remove extension
name = name.replace(/\..*$/, '');
return dust.cache[name] ? name : undefined;
};
server.engine('dust', function(name, options, fn) {
dust.render(name, _.omit(options, 'settings', '_locals'), fn);
});
server.set('view engine', 'dust');
/* Templates are compiled and cached on startup,
* so always let Express do its caching as well
*/
server.set('view cache', true);
// cannot remember what this is for
if(ENV === 'development')
server.set('trust proxy', true);
/* Dust dust very bad minifying, mercilessly concatting different
* text rows, so we need to set conserve whitespaces.
*/
dust.config.whitespace = true;
module.exports = server;