1
+ /* eslint-disable global-require */
1
2
require ( 'dotenv' ) . config ( ) ;
2
3
const CubejsServerCore = require ( '@cubejs-backend/server-core' ) ;
3
4
@@ -38,7 +39,7 @@ class CubejsServer {
38
39
res . end ( ) ;
39
40
} ) ;
40
41
this . redirector . listen ( PORT ) ;
41
- this . server = https . createServer ( options , app ) ;
42
+ this . server = Object . keys ( options ) . length ? https . createServer ( options , app ) : https . createServer ( app ) ;
42
43
this . server . listen ( TLS_PORT , err => {
43
44
if ( err ) {
44
45
this . server = null ;
@@ -48,10 +49,12 @@ class CubejsServer {
48
49
}
49
50
this . redirector . close = util . promisify ( this . redirector . close ) ;
50
51
this . server . close = util . promisify ( this . server . close ) ;
51
- resolve ( { app, port : PORT , tlsPort : TLS_PORT , server : this . server } ) ;
52
+ resolve ( {
53
+ app, port : PORT , tlsPort : TLS_PORT , server : this . server
54
+ } ) ;
52
55
} ) ;
53
56
} else {
54
- this . server = http . createServer ( options , app ) ;
57
+ this . server = Object . keys ( options ) . length ? http . createServer ( options , app ) : http . createServer ( app ) ;
55
58
this . server . listen ( PORT , err => {
56
59
if ( err ) {
57
60
this . server = null ;
@@ -64,10 +67,11 @@ class CubejsServer {
64
67
}
65
68
} ) ;
66
69
} catch ( e ) {
67
- this . core . event &&
68
- ( await this . core . event ( "Dev Server Fatal Error" , {
70
+ if ( this . core . event ) {
71
+ await this . core . event ( "Dev Server Fatal Error" , {
69
72
error : ( e . stack || e . message || e ) . toString ( )
70
- } ) ) ;
73
+ } ) ;
74
+ }
71
75
throw e ;
72
76
}
73
77
}
@@ -84,10 +88,11 @@ class CubejsServer {
84
88
this . redirector = null ;
85
89
}
86
90
} catch ( e ) {
87
- this . core . event &&
88
- ( await this . core . event ( "Dev Server Fatal Error" , {
91
+ if ( this . core . event ) {
92
+ await this . core . event ( "Dev Server Fatal Error" , {
89
93
error : ( e . stack || e . message || e ) . toString ( )
90
- } ) ) ;
94
+ } ) ;
95
+ }
91
96
throw e ;
92
97
}
93
98
}
0 commit comments