Merge pull request #332 from bmonty/bmonty/issue-318

move helmet and express.static before sessions for performance
This commit is contained in:
Liran Tal
2015-01-06 23:29:15 +02:00

View File

@@ -85,6 +85,16 @@ module.exports = function(db) {
app.use(bodyParser.json());
app.use(methodOverride());
// Use helmet to secure Express headers
app.use(helmet.xframe());
app.use(helmet.xssFilter());
app.use(helmet.nosniff());
app.use(helmet.ienoopen());
app.disable('x-powered-by');
// Setting the app router and static folder
app.use(express.static(path.resolve('./public')));
// CookieParser should be above session
app.use(cookieParser());
@@ -108,16 +118,6 @@ module.exports = function(db) {
// connect flash for flash messages
app.use(flash());
// Use helmet to secure Express headers
app.use(helmet.xframe());
app.use(helmet.xssFilter());
app.use(helmet.nosniff());
app.use(helmet.ienoopen());
app.disable('x-powered-by');
// Setting the app router and static folder
app.use(express.static(path.resolve('./public')));
// Globbing routing files
config.getGlobbedFiles('./app/routes/**/*.js').forEach(function(routePath) {
require(path.resolve(routePath))(app);
@@ -162,4 +162,4 @@ module.exports = function(db) {
// Return Express server instance
return app;
};
};