File tree Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Expand file tree Collapse file tree 1 file changed +8
-13
lines changed Original file line number Diff line number Diff line change @@ -5,24 +5,19 @@ import { Logger, ValidationPipe } from '@nestjs/common';
55import * as express from 'express' ;
66import { join } from 'path' ;
77import * as bodyParser from 'body-parser' ;
8- import { readFileSync } from 'fs' ;
8+ import { readFileSync , existsSync } from 'fs' ;
99import { HttpsOptions } from '@nestjs/common/interfaces/external/https-options.interface' ;
1010
1111function getHttpsOptions ( ) : HttpsOptions | null {
12- let cert : Buffer , key : Buffer ;
13- try {
14- key = readFileSync ( './secrets/ssl.key' ) ;
15- } catch ( err ) {
16- Logger . error ( './secrets/ssl.key not found' , err . stack ) ;
17- }
18- try {
19- cert = readFileSync ( './secrets/ssl.cert' ) ;
20- } catch ( err ) {
21- Logger . error ( './secrets/ssl.cert not found' , err . stack ) ;
12+ const keyPath = './secrets/ssl.key' ;
13+ const certPath = './secrets/cert.key' ;
14+ if ( ! existsSync ( keyPath ) || ! existsSync ( certPath ) ) {
15+ Logger . log ( 'HTTPS config not found. Fall back to HTTP' ) ;
16+ return null ;
2217 }
2318 return {
24- key,
25- cert,
19+ key : readFileSync ( keyPath ) ,
20+ cert : readFileSync ( certPath ) ,
2621 } ;
2722}
2823
You can’t perform that action at this time.
0 commit comments