import * as _ from 'lodash' ; import { Connection , createConnection } from 'typeorm' ; let connectionIfExists ; /**
 * Returns the DB connnection
 */ export function getDBConnection ( ) { if ( connectionIfExists === undefined ) { throw new Error ( 'DB connection not initialized' ) ; } return connectionIfExists ; } /**
 * Creates the DB connnection to use in an app
 */ export async function initDBConnectionAsync ( ) { if ( connectionIfExists !== undefined ) { throw new Error ( 'DB connection already exists' ) ; } connectionIfExists = await createConnection ( ) ; }