Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed express deprecated app.configure. Partial fix for #315 #327

Merged
merged 1 commit into from Aug 28, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
96 changes: 47 additions & 49 deletions app.js
Expand Up @@ -41,61 +41,59 @@ db.once('open', function () {
app.listen(app.get('port'));
});

app.configure(function () {
var sessionStore = new MongoStore({ mongoose_connection: db });
var sessionStore = new MongoStore({ mongoose_connection: db });

// See https://hacks.mozilla.org/2013/01/building-a-node-js-server-that-wont-melt-a-node-js-holiday-season-part-5/
app.use(function (aReq, aRes, aNext) {
// check if we're toobusy
if (toobusy()) {
statusCodePage(aReq, aRes, aNext, {
statusCode: 503,
statusMessage: 'We\'re busy right now. Try again later.',
});
} else {
aNext();
}
});
// See https://hacks.mozilla.org/2013/01/building-a-node-js-server-that-wont-melt-a-node-js-holiday-season-part-5/
app.use(function (aReq, aRes, aNext) {
// check if we're toobusy
if (toobusy()) {
statusCodePage(aReq, aRes, aNext, {
statusCode: 503,
statusMessage: 'We\'re busy right now. Try again later.',
});
} else {
aNext();
}
});

// Force HTTPS
if (app.get('port') === 443) {
app.use(function (aReq, aRes, aNext) {
aRes.setHeader('Strict-Transport-Security',
'max-age=8640000; includeSubDomains');
// Force HTTPS
if (app.get('port') === 443) {
app.use(function (aReq, aRes, aNext) {
aRes.setHeader('Strict-Transport-Security',
'max-age=8640000; includeSubDomains');

if (aReq.headers['x-forwarded-proto'] !== 'https') {
return aRes.redirect(301, 'https://' + aReq.headers.host + encodeURI(aReq.url));
}
if (aReq.headers['x-forwarded-proto'] !== 'https') {
return aRes.redirect(301, 'https://' + aReq.headers.host + encodeURI(aReq.url));
}

aNext();
});
}
aNext();
});
}

if (process.env.NODE_ENV !== 'production') {
app.use(express.logger('dev'));
}
if (process.env.NODE_ENV !== 'production') {
app.use(express.logger('dev'));
}

app.use(express.urlencoded());
app.use(express.json());
app.use(express.compress());
app.use(express.methodOverride());

// Order is very important here (i.e mess with at your own risk)
app.use(express.cookieParser());
app.use(express.session({
secret: sessionSecret,
store: sessionStore
}));
app.use(passport.initialize());
app.use(modifySessions.init(sessionStore));
app.use(app.router);
app.use(express.favicon('public/images/favicon.ico'));

// Set up the views
app.engine('html', require('./libs/muExpress').renderFile(app));
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
});
app.use(express.urlencoded());
app.use(express.json());
app.use(express.compress());
app.use(express.methodOverride());

// Order is very important here (i.e mess with at your own risk)
app.use(express.cookieParser());
app.use(express.session({
secret: sessionSecret,
store: sessionStore
}));
app.use(passport.initialize());
app.use(modifySessions.init(sessionStore));
app.use(app.router);
app.use(express.favicon('public/images/favicon.ico'));

// Set up the views
app.engine('html', require('./libs/muExpress').renderFile(app));
app.set('view engine', 'html');
app.set('views', __dirname + '/views');

// Emulate app.route('/').VERB(callback).VERB(callback); from ExpressJS 4.x
var methods = ['get', 'post', 'put', 'head', 'delete', 'options'];
Expand Down