forked from FoundKeyGang/FoundKey
✌️
This commit is contained in:
parent
6d3a4336d1
commit
2a8c959d09
3 changed files with 16 additions and 20 deletions
|
@ -16,14 +16,11 @@ secondary_url:
|
|||
# 待受ポート
|
||||
port:
|
||||
|
||||
# TLSの設定
|
||||
# TLSの設定(利用しない場合は省略可能)
|
||||
https:
|
||||
# TLSを有効にするか否か
|
||||
enable: false
|
||||
|
||||
key: null
|
||||
cert: null
|
||||
ca: null
|
||||
# 証明書のパス...
|
||||
key:
|
||||
cert:
|
||||
|
||||
# MongoDBの設定
|
||||
mongodb:
|
||||
|
|
|
@ -38,12 +38,7 @@ type Source = {
|
|||
url: string;
|
||||
secondary_url: string;
|
||||
port: number;
|
||||
https: {
|
||||
enable: boolean;
|
||||
key: string;
|
||||
cert: string;
|
||||
ca: string;
|
||||
};
|
||||
https?: { [x: string]: string };
|
||||
mongodb: {
|
||||
host: string;
|
||||
port: number;
|
||||
|
|
|
@ -61,13 +61,17 @@ app.use(require('./web/server'));
|
|||
/**
|
||||
* Create server
|
||||
*/
|
||||
const server = config.https.enable ?
|
||||
https.createServer({
|
||||
key: fs.readFileSync(config.https.key),
|
||||
cert: fs.readFileSync(config.https.cert),
|
||||
ca: fs.readFileSync(config.https.ca)
|
||||
}, app) :
|
||||
http.createServer(app);
|
||||
const server = (() => {
|
||||
if (config.https) {
|
||||
const certs = {};
|
||||
Object.keys(config.https).forEach(k => {
|
||||
certs[k] = fs.readFileSync(config.https[k]);
|
||||
});
|
||||
return https.createServer(certs, app);
|
||||
} else {
|
||||
return http.createServer(app);
|
||||
}
|
||||
})();
|
||||
|
||||
/**
|
||||
* Steaming
|
||||
|
|
Loading…
Reference in a new issue