Created
July 21, 2016 12:21
-
-
Save punmechanic/87b106b75364a9b1df956179c4692958 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const express = require('express') | |
const LEX = require('letsencrypt-express').testing() | |
const DOMAIN = 'localhost' | |
const EMAIL = 'devnull@danpantry.me' | |
const lex = LEX.create({ | |
configDir: require('os').homedir() + '/letsencrypt/etc', | |
approveRegistration(hostname, approve) { | |
if (hostname === DOMAIN) { | |
approve(null, { domains: [DOMAIN], email: EMAIL, agreeTos: true }) | |
} | |
} | |
}) | |
const app = express() | |
app.use(function (req, res) { | |
// You can now use push here etc as 'res' is a Spdy response object. | |
res.send('Hello, world!') | |
res.end() | |
}) | |
lex.onRequest = app | |
lex.listen([80], [443, 5001], function () { | |
const protocol = 'requestCert' in this ? 'https' : 'http' | |
console.log(`listening at ${protocol}://localhost:${this.address().port}`) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment