forked from noxious/server
Continuation of refactor
This commit is contained in:
@ -1,20 +1,21 @@
|
||||
import { EntityManager } from '@mikro-orm/core'
|
||||
import { MikroORM } from '@mikro-orm/mysql'
|
||||
|
||||
import { appLogger } from './logger'
|
||||
import Logger, { LoggerType } from './logger'
|
||||
import config from '../../mikro-orm.config'
|
||||
|
||||
class Database {
|
||||
private static orm: MikroORM
|
||||
private static em: EntityManager
|
||||
private static logger = Logger.type(LoggerType.APP)
|
||||
|
||||
public static async initialize(): Promise<void> {
|
||||
try {
|
||||
Database.orm = await MikroORM.init(config)
|
||||
Database.em = Database.orm.em.fork()
|
||||
appLogger.info('Database connection initialized')
|
||||
this.logger.info('Database connection initialized')
|
||||
} catch (error) {
|
||||
appLogger.error(`MikroORM connection failed: ${error}`)
|
||||
this.logger.error(`MikroORM connection failed: ${error}`)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user