express-enforces-ssl
Advanced tools
Comparing version 0.6.0 to 1.0.0
39
index.js
@@ -1,28 +0,27 @@ | ||
"use strict"; | ||
var enforceHTTPS = function(force_hard) { | ||
return function(req, res, next) { | ||
(function(module) { | ||
'use strict'; | ||
if(force_hard) { | ||
redirectUrl(req, res); | ||
module.exports = function enforceHTTPS() { | ||
return function(req, res, next) { | ||
var isHttps = req.secure; | ||
if(isHttps){ | ||
next(); | ||
} else { | ||
redirectUrl(req); | ||
} | ||
} | ||
}; | ||
var isHttps = req.secure; | ||
if(isHttps){ | ||
next(); | ||
var redirectUrl = function (req, res) { | ||
if(req.method === "GET") { | ||
res.redirect(301, "https://" + req.headers.host + req.originalUrl); | ||
} else { | ||
redirectUrl(req); | ||
res.send(403, "Please use HTTPS when submitting data to this server."); | ||
} | ||
} | ||
}; | ||
var redirectUrl = function (req, res) { | ||
if(req.method === "GET") { | ||
res.redirect(301, "https://" + req.headers.host + req.originalUrl); | ||
} else { | ||
res.send(403, "Please use HTTPS when submitting data to this server."); | ||
} | ||
} | ||
exports.HTTPS = enforceHTTPS; | ||
})(module); |
{ | ||
"name": "express-enforces-ssl", | ||
"version": "0.6.0", | ||
"version": "1.0.0", | ||
"description": "Enforces SSL for node.js express projects", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -24,8 +24,14 @@ express-enforces-ssl | ||
// use HTTPS(true) in case you are behind a load balancer (e.g. Heroku) | ||
app.use(express_enforces_ssl.HTTPS()); | ||
app.enable('trust proxy'); | ||
app.use(express_enforces_ssl()); | ||
/* | ||
Routes Here | ||
*/ | ||
http.createServer(app).listen(app.get('port'), function() { | ||
console.log('Express server listening on port ' + app.get('port')); | ||
}); | ||
``` | ||
@@ -32,0 +38,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
41
2292
20