@reldens/server-utils 0.31.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/app-server-factory.js +11 -3
- package/package.json +1 -1
|
@@ -16,6 +16,7 @@ const express = require('express');
|
|
|
16
16
|
const bodyParser = require('body-parser');
|
|
17
17
|
const session = require('express-session');
|
|
18
18
|
const compression = require('compression');
|
|
19
|
+
const tls = require('tls');
|
|
19
20
|
|
|
20
21
|
class AppServerFactory
|
|
21
22
|
{
|
|
@@ -113,9 +114,16 @@ class AppServerFactory
|
|
|
113
114
|
this.setupRateLimiting();
|
|
114
115
|
this.setupRequestParsing();
|
|
115
116
|
this.setupTrustedProxy();
|
|
116
|
-
|
|
117
|
+
try {
|
|
118
|
+
this.appServer = this.createServer();
|
|
119
|
+
} catch (error) {
|
|
120
|
+
this.error = {message: 'Server creation exception: ' + error.message};
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
117
123
|
if(!this.appServer){
|
|
118
|
-
this.error
|
|
124
|
+
if(!this.error.message){
|
|
125
|
+
this.error = {message: 'The createServer() returned false - check certificate paths and permissions'};
|
|
126
|
+
}
|
|
119
127
|
return false;
|
|
120
128
|
}
|
|
121
129
|
if(this.autoListen){
|
|
@@ -387,7 +395,7 @@ class AppServerFactory
|
|
|
387
395
|
this.error = {message: 'Could not read domain SSL certificate: '+domain.certPath};
|
|
388
396
|
return callback(null, null);
|
|
389
397
|
}
|
|
390
|
-
let ctx =
|
|
398
|
+
let ctx = tls.createSecureContext({key, cert});
|
|
391
399
|
callback(null, ctx);
|
|
392
400
|
};
|
|
393
401
|
return https.createServer(httpsOptions, this.app);
|