mirror of
				https://github.com/therootcompany/greenlock-express.js.git
				synced 2024-11-16 17:28:59 +00:00 
			
		
		
		
	slight simplification of examples
This commit is contained in:
		
							parent
							
								
									c3d496531b
								
							
						
					
					
						commit
						a48c10e082
					
				
							
								
								
									
										15
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								README.md
									
									
									
									
									
								
							| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
							
								
								
									
										15
									
								
								examples/my-express-app.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								examples/my-express-app.js
									
									
									
									
									
										Normal 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; | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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'); | ||||
|  | ||||
| @ -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); | ||||
| }); | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
| @ -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" | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user