import 'reflect-metadata' ; import { Connection , createConnection , getConnectionOptions } from 'typeorm' ; import { User } from '../entities/User' ; export const initializeDatabase = async ( optionOverrides = { } ) : Promise < Connection > => { const connectionOptions = await getConnectionOptions ( ) ; const options = { ... connectionOptions , entities : [ User ] , migrations : [ __dirname + '/migrations/*.ts' ] , ... optionOverrides } ; const connection = await createConnection ( options ) ; return connection ; } ; export default initializeDatabase ;