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
version: 'draft-11'
, server: 'https://acme-v02.api.letsencrypt.org/directory'
// Note: If at first you don't succeed, switch to staging to debug
// 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
, 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
// NOTE: all domains will validated and listed on the certificate
, approveDomains: [ 'example.com', 'www.example.com' ]
// You MUST have access to write to directory where certs are saved
// ex: /home/foouser/acme/etc
, configDir: require('path').join(require('os').homedir(), 'acme', 'etc')
// You MUST NOT build clients that accept the ToS without asking the user
, agreeTos: true
, app: require('express')().use('/', function (req, res) {
res.setHeader('Content-Type', 'text/html; charset=utf-8')
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
// 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
// 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
, communityMember: true

View File

@ -24,7 +24,7 @@ var greenlock = Greenlock.create({
// You MUST have access to write to directory where certs are saved
// 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
, 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';
//
// 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
//
@ -19,11 +7,12 @@ app.use('/', function (req, res) {
require('../').create({
// 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
// 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,
// but this example uses approveDomains() to set them dynamically
@ -34,11 +23,7 @@ require('../').create({
// email addresses with domains and agreements and such
, approveDomains: approveDomains
// You MUST have access to write to directory where certs are saved
// ex: /etc/greenlock/
, configDir: '/tmp/etc/greenlock'
, app: app
, app: require('./my-express-app.js')
// Get notified of important updates and help me make greenlock better
, communityMember: true

View File

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

View File

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

View File

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

View File

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