-
Notifications
You must be signed in to change notification settings - Fork 1
/
express-config.js
52 lines (43 loc) · 1.31 KB
/
express-config.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
'use strict';
var express = require('express'),
path = require('path');
/**
* Express configuration
*/
module.exports = function(app) {
var rootPath = path.normalize(__dirname + '/');
app.configure('development', function(){
// Disable caching of scripts for easier testing
app.use(function noCache(req, res, next) {
if (req.url.indexOf('/scripts/') === 0) {
res.header('Cache-Control', 'no-cache, no-store, must-revalidate');
res.header('Pragma', 'no-cache');
res.header('Expires', 0);
}
next();
});
app.use(express.static(path.join(rootPath, '.tmp')));
app.use(express.static(path.join(rootPath)));
app.set('views', rootPath);
});
app.configure('production', function(){
app.use(express.favicon(path.join(rootPath, 'public', 'favicon.ico')));
app.use(express.static(path.join(rootPath)));
app.set('views', rootPath);
});
app.configure(function(){
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.cookieParser());
// Router (only error handlers should come after this)
app.use(app.router);
});
// Error handler
app.configure('development', function(){
app.use(express.errorHandler());
});
};