Skip to content

Commit

Permalink
Update example so it works out of the box with local Pebble server
Browse files Browse the repository at this point in the history
  • Loading branch information
aral committed Jul 10, 2020
1 parent 17c4217 commit c1cc01a
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
//
// Plain Node HTTPS server example using Auto Encrypt.
//
// For this example to work, make sure:
// This example uses the local Pebble testing server.
//
// Before you alter it to use the Let’s Encrypt staging or production servers, ensure that:
//
// 1. You have your hostname set correctly for your system.
//
Expand All @@ -24,22 +26,29 @@

const os = require('os')
const AutoEncrypt = require('../index')
const Pebble = require('@small-tech/node-pebble')

console.log('\n 🌄 Auto Encrypt “Hello, world!” Example \n')

options = {
/* Custom http server options, if any, go here (we don’t have any in this
example, so we could just not have passed this empty object at all). */
async function main() {

serverType: AutoEncrypt.serverType.PEBBLE, // (The default is .PRODUCTION.)
domains: [os.hostname(), `www.${os.hostname()}`]
}
// Pebble is the local Let’s Encrypt testing server.
await Pebble.ready()

options = {
/* Custom http server options, if any, go here (we don’t have any in this
example, so we could just not have passed this empty object at all). */

const server = AutoEncrypt.https.createServer(options, (request, response) => {
response.end('Hello, world!')
})
serverType: AutoEncrypt.serverType.PEBBLE // (The default is .PRODUCTION.)
}

const server = AutoEncrypt.https.createServer(options, (request, response) => {
response.end('Hello, world!')
})

server.listen(443, () => {
console.log(`\n ✨ “Hello, world!” server is running at https://localhost:${server.address().port}…\n`)
})
}

server.listen(443, () => {
console.log(`\n ✨ “Hello, world!” server is running…\n`)
console.log(server.address())
})
main()

0 comments on commit c1cc01a

Please sign in to comment.