Skip to content

Instantly share code, notes, and snippets.

@punmechanic
Created July 21, 2016 12:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save punmechanic/87b106b75364a9b1df956179c4692958 to your computer and use it in GitHub Desktop.
Save punmechanic/87b106b75364a9b1df956179c4692958 to your computer and use it in GitHub Desktop.
'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