From 8c25386767759d5f7e03852ca59714ff153cf713 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 22 Aug 2018 16:36:33 -0600 Subject: [PATCH] improve style --- index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index cfaa297..74e2e15 100644 --- a/index.js +++ b/index.js @@ -93,11 +93,14 @@ module.exports.create = function (opts) { return promise; } + // NOTE: 'greenlock' is just 'opts' renamed var greenlock = require('greenlock').create(opts); - opts.app = opts.app || function (req, res) { - res.end("Hello, World!\nWith Love,\nGreenlock for Express.js"); - }; + if (!opts.app) { + opts.app = function (req, res) { + res.end("Hello, World!\nWith Love,\nGreenlock for Express.js"); + }; + } opts.listen = function (plainPort, port, fnPlain, fn) { var promises = []; @@ -135,7 +138,12 @@ module.exports.create = function (opts) { server.unencrypted = plainServer; return server; }; - + opts.middleware.acme = function (opts) { + return greenlock.middleware.sanitizeHost(greenlock.middleware(require('redirect-https')(opts))); + }; + opts.middleware.secure = function (app) { + return greenlock.middleware.sanitizeHost(app); + }; return greenlock; };