more attention on the simple example

This commit is contained in:
AJ ONeal 2019-10-29 23:04:32 -06:00
parent df1259cd9d
commit 894a01fa4e
1 changed files with 30 additions and 10 deletions

View File

@ -6,22 +6,42 @@
Free SSL, Automated HTTPS / HTTP2, served with Node via Express, Koa, hapi, etc. Free SSL, Automated HTTPS / HTTP2, served with Node via Express, Koa, hapi, etc.
### Let's Encrypt for Node, Express, etc
```js ```js
require("greenlock-express") require("greenlock-express")
.init(getConfig) .init(function getConfig() {
.serve(worker); return { package: require("./package.json") };
})
.serve(httpsWorker);
function getConfig() { function httpsWorker(server) {
return { // Works with any Node app (Express, etc)
package: require("./package.json") var app = require("./my-express-app.js");
};
}
function worker(server) { // See, all normal stuff here
server.serveApp(function(req, res) { app.get("/hello", function(req, res) {
// Works with any Node app (Express, etc)
res.end("Hello, Encrypted World!"); res.end("Hello, Encrypted World!");
}); });
// Serves on 80 and 443
// Get's SSL certificates magically!
server.serveApp(app);
}
```
Manage via API or the config file:
```json
{
"subscriberEmail": "letsencrypt-test@therootcompany.com",
"agreeToTerms": true,
"sites": {
"example.com": {
"subject": "example.com",
"altnames": ["example.com", "www.example.com"]
}
}
} }
``` ```