removed some logic from index

This commit is contained in:
Ulf Gebhardt 2021-09-24 14:44:18 +02:00
parent 66324fe1ca
commit e092af22e3
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
2 changed files with 16 additions and 16 deletions

View File

@ -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`)
}

View File

@ -2,18 +2,21 @@ import { createConnection, Connection } from 'typeorm'
import CONFIG from '../config'
import path from 'path'
const connection = async (): Promise<Connection> => {
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<Connection | null> => {
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
}