11import { NestFactory } from '@nestjs/core' ;
2- import { NestExpressApplication } from '@nestjs/platform-express' ;
2+ import { ExpressAdapter , NestExpressApplication } from '@nestjs/platform-express' ;
33import cookieParser from 'cookie-parser' ;
4- import { Response } from 'express' ;
4+ import express , { Response } from 'express' ;
55import passport from 'passport' ;
66import { rawBodyBuffer } from '~/_common/middlewares/raw-body-buffer.middleware' ;
77import { getLogLevel } from './_common/functions/get-log-level' ;
88import { AppModule } from './app.module' ;
99import configInstance from './config' ;
1010import { InternalLogger } from './core/logger/internal.logger' ;
1111import { readFileSync } from 'fs' ;
12+ import * as http from 'http' ;
13+ import * as https from 'https' ;
14+ import { ShutdownObserver } from './_common/observers/shutdown.observer' ;
1215
1316declare const module : any ;
1417( async ( ) : Promise < void > => {
@@ -34,7 +37,8 @@ declare const module: any;
3437 }
3538 }
3639
37- const app = await NestFactory . create < NestExpressApplication > ( AppModule , {
40+ const server = express ( ) ;
41+ const app = await NestFactory . create < NestExpressApplication > ( AppModule , new ExpressAdapter ( server ) , {
3842 bodyParser : false ,
3943 rawBody : true ,
4044 cors : true ,
@@ -52,9 +56,18 @@ declare const module: any;
5256 await ( await import ( './swagger' ) ) . default ( app ) ;
5357 }
5458
55- await app . listen ( 4000 , async ( ) : Promise < void > => {
56- logger . log ( `Sesame - Orchestrator is READY on <http://127.0.0.1:4000> !` ) ;
57- } ) ;
59+ await app . init ( ) ;
60+
61+ const shutdownObserver = app . get ( ShutdownObserver ) ;
62+ const httpServer = http . createServer ( server ) . listen ( 4000 ) ;
63+ shutdownObserver . addHttpServer ( httpServer ) ;
64+ logger . log ( `Sesame - Orchestrator is READY on <http://127.0.0.1:4000> !` ) ;
65+
66+ if ( cfg . application ?. https ?. enabled ) {
67+ const httpsServer = https . createServer ( extraOptions . httpsOptions ! , server ) . listen ( 4443 ) ;
68+ shutdownObserver . addHttpServer ( httpsServer ) ;
69+ logger . log ( `Sesame - Orchestrator is READY on <https://127.0.0.1:4443> !` ) ;
70+ }
5871
5972 if ( module . hot ) {
6073 module . hot . accept ( ) ;
0 commit comments