Check config on load (#4170)

Co-authored-by: syuilo <syuilotan@yahoo.co.jp>
This commit is contained in:
Aya Morisawa
2019-02-06 22:44:55 +09:00
committed by syuilo
parent 41ba06a5e6
commit 96bc17aa10
19 changed files with 195 additions and 125 deletions

View File

@ -96,13 +96,14 @@ app.use(router.routes());
app.use(mount(require('./web')));
function createServer() {
if (config.https) {
const certs: any = {};
for (const k of Object.keys(config.https)) {
certs[k] = fs.readFileSync(config.https[k]);
}
certs['allowHTTP1'] = true;
return http2.createSecureServer(certs, app.callback()) as https.Server;
if (config.https.isJust()) {
const opts = {
key: fs.readFileSync(config.https.get().key),
cert: fs.readFileSync(config.https.get().cert),
...config.https.get().ca.map<any>(path => ({ ca: fs.readFileSync(path) })).getOrElse({}),
allowHTTP1: true
};
return http2.createSecureServer(opts, app.callback()) as https.Server;
} else {
return http.createServer(app.callback());
}