From e092af22e3f2edd51039353ee98e182daea48d12 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 24 Sep 2021 14:44:18 +0200 Subject: [PATCH] removed some logic from index --- backend/src/index.ts | 5 +---- backend/src/typeorm/connection.ts | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index 18ac9d9c1..1c3814096 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -26,10 +26,7 @@ const DB_VERSION = '0001-init_db' async function main() { // open mysql connection - let con = null - try { - con = await connection() - } catch (error) {} + const con = await connection() if (!con || !con.isConnected) { throw new Error(`Couldn't open connection to database`) } diff --git a/backend/src/typeorm/connection.ts b/backend/src/typeorm/connection.ts index b108c5ef5..db7dbcb29 100644 --- a/backend/src/typeorm/connection.ts +++ b/backend/src/typeorm/connection.ts @@ -2,18 +2,21 @@ import { createConnection, Connection } from 'typeorm' import CONFIG from '../config' import path from 'path' -const connection = async (): Promise => { - const con = await createConnection({ - name: 'default', - type: 'mysql', - host: CONFIG.DB_HOST, - port: CONFIG.DB_PORT, - username: CONFIG.DB_USER, - password: CONFIG.DB_PASSWORD, - database: CONFIG.DB_DATABASE, - entities: [path.join(__dirname, 'entity', '*.ts')], - synchronize: false, - }) +const connection = async (): Promise => { + let con = null + try { + con = await createConnection({ + name: 'default', + type: 'mysql', + host: CONFIG.DB_HOST, + port: CONFIG.DB_PORT, + username: CONFIG.DB_USER, + password: CONFIG.DB_PASSWORD, + database: CONFIG.DB_DATABASE, + entities: [path.join(__dirname, 'entity', '*.ts')], + synchronize: false, + }) + } catch (error) {} return con }