-
Notifications
You must be signed in to change notification settings - Fork 0
/
express.js
61 lines (46 loc) · 1.59 KB
/
express.js
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
'use strict';
/**
* Module dependencies.
*/
var mean = require('meanio'),
compression = require('compression'),
morgan = require('morgan'),
consolidate = require('consolidate'),
express = require('express'),
helpers = require('view-helpers'),
flash = require('connect-flash'),
modRewrite = require('connect-modrewrite'),
seo = require('mean-seo'),
config = mean.loadConfig();
module.exports = function(app, db) {
app.set('showStackError', true);
// Prettify HTML
app.locals.pretty = true;
// cache=memory or swig dies in NODE_ENV=production
app.locals.cache = 'memory';
// Should be placed before express.static
// To ensure that all assets and data are compressed (utilize bandwidth)
app.use(compression({
// Levels are specified in a range of 0 to 9, where-as 0 is
// no compression and 9 is best compression, but slowest
level: 9
}));
// Enable compression on bower_components
app.use('/bower_components', express.static(config.root + '/bower_components'));
// Only use logger for development environment
if (process.env.NODE_ENV === 'development') {
app.use(morgan('dev'));
}
// assign the template engine to .html files
app.engine('html', consolidate[config.templateEngine]);
// set .html as the default extension
app.set('view engine', 'html');
// Dynamic helpers
app.use(helpers(config.app.name));
// Connect flash for flash messages
app.use(flash());
app.use(modRewrite([
'!^/api/.*|\\_getModules|\\.html|\\.js|\\.css|\\.swf|\\.jp(e?)g|\\.png|\\.gif|\\.svg|\\.eot|\\.ttf|\\.woff|\\.pdf$ / [L]'
]));
app.use(seo());
};