Stackedit/server.js

25 lines
610 B
JavaScript
Raw Normal View History

2013-09-27 23:41:15 +00:00
var express = require('express');
var app = express();
2013-10-07 01:17:55 +00:00
// Force HTTPS on stackedit.io
2013-10-07 01:11:56 +00:00
app.all('*', function(req, res, next) {
if (req.headers.host == 'stackedit.io' && req.headers['x-forwarded-proto'] != 'https') {
res.redirect('https://stackedit.io' + req.url);
}
else {
next();
}
});
2013-10-07 01:17:55 +00:00
// Use gzip compression
2013-09-27 23:41:15 +00:00
app.use(express.compress());
2013-10-07 01:17:55 +00:00
// Serve static resources
2013-10-06 20:26:11 +00:00
app.use(express.static(__dirname + '/public'));
2013-10-07 01:17:55 +00:00
// Listen on port 3000
2013-10-09 23:51:35 +00:00
var port = process.env.PORT || 3000;
app.listen(port, null, function() {
console.log('Server started: http://localhost:' + port);
});