import 'reflect-metadata' ; import { createConnection , Connection } from 'typeorm' ; import { ENV } from '@config/environment.config' ; import { Logger } from '@services/logger.service' ; see https export class Database { constructor ( ) { } description async static connect ( options ) { createConnection ( { type : options . TYPE , name : options . NAME , host : options . HOST , port : options . PORT , username : options . USER , password : options . PWD , database : options . DB , entities : options . ENTITIES , subscribers : options . SUBSCRIBERS , synchronize : options . SYNC , logging : options . LOG , cache : options . CACHE } as any ) . then ( ( connection ) => { Logger . log ( 'info' , `Connection to MySQL server established on port ${ options . PORT as string } (${ ENV })` ) ; } ) . catch ( ( error ) => { process . stdout . write ( `error: ${ error . message }` ) ; process . exit ( 1 ) ; } ) ; } }