import { ApplicationServer } from '../application-server' ; import { AppModule , cli , Command , flag , ServiceContainer } from '@deepkit/app' ; import { DefaultFormatter , Logger } from '@deepkit/logger' ; import { FrameworkModule } from '../module' ; @ cli . controller ( 'server:start' , { description : 'Starts the application server. If HTTP or RPC controllers or a publicDir are provided this will include an HTTP listener' } ) export class ServerStartController implements Command { constructor ( protected logger , protected serviceContainer ) { } async execute ( @ flag . optional host ? , @ flag . optional port ? , @ flag . optional workers ? , @ flag . optional ssl ? , @ flag . optional selfSigned ? ) { if ( ! this . logger . hasFormatters ( ) ) this . logger . addFormatter ( new DefaultFormatter ) ; const overwrite = { } ; if ( host ) overwrite . host = host ; if ( port ) overwrite . port = port ; if ( workers ) overwrite . workers = workers ; if ( ssl ) overwrite . ssl = { } ; if ( selfSigned ) overwrite . selfSigned = selfSigned ; const kernel = this . serviceContainer . getModule ( FrameworkModule ) as AppModule < any > ; kernel . configure ( overwrite ) ; const server = this . serviceContainer . getRootInjector ( ) . get ( ApplicationServer ) ; await server . start ( true ) ; } }