slight simplification of examples

This commit is contained in:
AJ ONeal 2018-07-03 03:25:12 -06:00
parent c3d496531b
commit a48c10e082
10 changed files with 37 additions and 39 deletions

View File

@ -147,30 +147,29 @@ require('greenlock-express').create({
// Let's Encrypt v2 is ACME draft 11 // Let's Encrypt v2 is ACME draft 11
version: 'draft-11' version: 'draft-11'
, server: 'https://acme-v02.api.letsencrypt.org/directory'
// Note: If at first you don't succeed, switch to staging to debug // Note: If at first you don't succeed, switch to staging to debug
// https://acme-staging-v02.api.letsencrypt.org/directory // https://acme-staging-v02.api.letsencrypt.org/directory
, server: 'https://acme-v02.api.letsencrypt.org/directory'
// Where the certs will be saved, MUST have write access
, configDir: '~/.config/acme/'
// You MUST change this to a valid email address // You MUST change this to a valid email address
, email: 'john.doe@example.com' , email: 'john.doe@example.com'
// You MUST NOT build clients that accept the ToS without asking the user
, agreeTos: true
// You MUST change these to valid domains // You MUST change these to valid domains
// NOTE: all domains will validated and listed on the certificate // NOTE: all domains will validated and listed on the certificate
, approveDomains: [ 'example.com', 'www.example.com' ] , approveDomains: [ 'example.com', 'www.example.com' ]
// You MUST have access to write to directory where certs are saved // You MUST NOT build clients that accept the ToS without asking the user
// ex: /home/foouser/acme/etc , agreeTos: true
, configDir: require('path').join(require('os').homedir(), 'acme', 'etc')
, app: require('express')().use('/', function (req, res) { , app: require('express')().use('/', function (req, res) {
res.setHeader('Content-Type', 'text/html; charset=utf-8') res.setHeader('Content-Type', 'text/html; charset=utf-8')
res.end('Hello, World!\n\n💚 🔒.js'); res.end('Hello, World!\n\n💚 🔒.js');
}) })
// Join the community to get notified of important updates and help me make greenlock better // Join the community to get notified of important updates
, communityMember: true , communityMember: true
// Contribute telemetry data to the project // Contribute telemetry data to the project

View File

@ -26,7 +26,7 @@ var greenlock = Greenlock.create({
// You MUST have access to write to directory where certs are saved // You MUST have access to write to directory where certs are saved
// ex: /home/foouser/acme/etc // ex: /home/foouser/acme/etc
, configDir: require('path').join(require('os').homedir(), 'acme', 'etc') , configDir: '~/.config/acme/'
// Get notified of important updates and help me make greenlock better // Get notified of important updates and help me make greenlock better
, communityMember: true , communityMember: true

View File

@ -24,7 +24,7 @@ var greenlock = Greenlock.create({
// You MUST have access to write to directory where certs are saved // You MUST have access to write to directory where certs are saved
// ex: /home/foouser/acme/etc // ex: /home/foouser/acme/etc
, configDir: require('path').join(require('os').homedir(), 'acme', 'etc') , configDir: '~/.config/acme/'
// Get notified of important updates and help me make greenlock better // Get notified of important updates and help me make greenlock better
, communityMember: true , communityMember: true

View File

@ -0,0 +1,15 @@
'use strict';
var express = require('express');
var app = express();
app.use('/', function (req, res) {
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.end('Hello, World!\n\n💚 🔒.js');
});
// DO NOT DO app.listen() unless we're testing this directly
if (require.main === module) { app.listen(3000); }
// Instead do export the app:
module.exports = app;

View File

@ -1,17 +1,5 @@
'use strict'; 'use strict';
//
// My Express App
//
var express = require('express');
var app = express();
app.use('/', function (req, res) {
res.setHeader('Content-Type', 'text/html; charset=utf-8')
res.end('Hello, World!\n\n💚 🔒.js');
});
// //
// My Secure Server // My Secure Server
// //
@ -19,11 +7,12 @@ app.use('/', function (req, res) {
require('../').create({ require('../').create({
// Let's Encrypt v2 is ACME draft 11 // Let's Encrypt v2 is ACME draft 11
version: 'draft-11'
, server: 'https://acme-v02.api.letsencrypt.org/directory'
// Note: If at first you don't succeed, stop and switch to staging // Note: If at first you don't succeed, stop and switch to staging
// https://acme-staging-v02.api.letsencrypt.org/directory // https://acme-staging-v02.api.letsencrypt.org/directory
server: 'https://acme-v02.api.letsencrypt.org/directory'
, version: 'draft-11'
// You MUST have write access to save certs
, configDir: '~/.config/acme/'
// The previous 'simple' example set these values statically, // The previous 'simple' example set these values statically,
// but this example uses approveDomains() to set them dynamically // but this example uses approveDomains() to set them dynamically
@ -34,11 +23,7 @@ require('../').create({
// email addresses with domains and agreements and such // email addresses with domains and agreements and such
, approveDomains: approveDomains , approveDomains: approveDomains
// You MUST have access to write to directory where certs are saved , app: require('./my-express-app.js')
// ex: /etc/greenlock/
, configDir: '/tmp/etc/greenlock'
, app: app
// Get notified of important updates and help me make greenlock better // Get notified of important updates and help me make greenlock better
, communityMember: true , communityMember: true

View File

@ -25,7 +25,7 @@ require('../').create({
, email: email , email: email
, agreeTos: agreeLeTos , agreeTos: agreeLeTos
, approveDomains: domains , approveDomains: domains
, configDir: require('path').join(require('os').homedir(), 'acme', 'etc') , configDir: '~/.config/acme/'
, app: remoteAccess(secret) , app: remoteAccess(secret)
// Get notified of important updates and help me make greenlock better // Get notified of important updates and help me make greenlock better
, communityMember: true , communityMember: true

View File

@ -22,7 +22,7 @@ require('../').create({
// You MUST have access to write to directory where certs are saved // You MUST have access to write to directory where certs are saved
// ex: /home/foouser/acme/etc // ex: /home/foouser/acme/etc
, configDir: require('path').join(require('os').homedir(), 'acme', 'etc') , configDir: '~/.config/acme/'
, app: require('express')().use('/', function (req, res) { , app: require('express')().use('/', function (req, res) {
res.setHeader('Content-Type', 'text/html; charset=utf-8'); res.setHeader('Content-Type', 'text/html; charset=utf-8');

View File

@ -26,7 +26,7 @@ var greenlock = Greenlock.create({
// You MUST have access to write to directory where certs are saved // You MUST have access to write to directory where certs are saved
// ex: /home/foouser/acme/etc // ex: /home/foouser/acme/etc
, configDir: require('path').join(require('os').homedir(), 'acme', 'etc') , configDir: '~/.config/acme/' // MUST have write access
// Get notified of important updates and help me make greenlock better // Get notified of important updates and help me make greenlock better
, communityMember: true , communityMember: true
@ -57,10 +57,8 @@ require('http').createServer(acmeChallengeHandler).listen(80, function () {
// spdy is a drop-in replacement for the https API // spdy is a drop-in replacement for the https API
var spdyOptions = Object.assign({}, greenlock.tlsOptions); var spdyOptions = Object.assign({}, greenlock.tlsOptions);
spdyOptions.spdy = { protocols: [ 'h2', 'http/1.1' ], plain: false }; spdyOptions.spdy = { protocols: [ 'h2', 'http/1.1' ], plain: false };
var server = require('spdy').createServer(spdyOptions, require('express')().use('/', function (req, res) { var myApp = require('./my-express-app.js');
res.setHeader('Content-Type', 'text/html; charset=utf-8'); var server = require('spdy').createServer(spdyOptions, myApp);
res.end('Hello, SPDY World!\n\n💚 🔒.js');
}));
server.on('error', function (err) { server.on('error', function (err) {
console.error(err); console.error(err);
}); });

View File

@ -69,7 +69,7 @@ require('../').create({
// You MUST have access to write to directory where certs are saved // You MUST have access to write to directory where certs are saved
// ex: /home/foouser/acme/etc // ex: /home/foouser/acme/etc
, configDir: require('path').join(require('os').homedir(), 'acme', 'etc') , configDir: '~/.config/acme/'
, app: function (req, res) { , app: function (req, res) {
console.log(req.headers.host); console.log(req.headers.host);

View File

@ -25,7 +25,8 @@
"express-basic-auth": "^1.1.5", "express-basic-auth": "^1.1.5",
"finalhandler": "^1.1.1", "finalhandler": "^1.1.1",
"serve-index": "^1.9.1", "serve-index": "^1.9.1",
"serve-static": "^1.13.2" "serve-static": "^1.13.2",
"ws": "^5.2.1"
}, },
"scripts": { "scripts": {
"test": "node examples/simple.js" "test": "node examples/simple.js"