import { ApplicationConfig , PubnubExampleApplication } from './application' ; export * from './application' ; const PORT = 3000 ; export async function main ( options = { } ) { const app = new PubnubExampleApplication ( options ) ; await app . boot ( ) ; await app . start ( ) ; const url = app . restServer . url ; console . log ( `Server is running at ${ url }` ) ; console . log ( `Try ${ url }/ping` ) ; return app ; } if ( require . main === module ) { const config = { rest : { port : + ( process . env . PORT ?? PORT ) , host : process . env . HOST , gracePeriodForClose : 5000 , openApiSpec : { setServersFromRequest : true , } , } , } ; main ( config ) . catch ( err => { console . error ( 'Cannot start the application.' , err ) ; process . exit ( 1 ) ; } ) ; }