Рефакторинг

This commit is contained in:
Book Pauk
2019-10-29 19:05:21 +07:00
parent a318568b72
commit 97ef1ee201
3 changed files with 4 additions and 7 deletions

View File

@@ -1,6 +1,5 @@
const fs = require('fs-extra');
const Logger = require('./Logger');
const configManager = new (require('../config'))();//singleton
let instance = null;
@@ -15,11 +14,10 @@ class AppLogger {
return instance;
}
async init() {
async init(config) {
if (this.inited)
throw new Error('already inited');
let config = configManager.config;
let loggerParams = null;
if (config.loggingEnabled) {

View File

@@ -1,7 +1,6 @@
const fs = require('fs-extra');
const SqliteConnectionPool = require('./SqliteConnectionPool');
const configManager = new (require('../config'))();//singleton
const log = new (require('../core/AppLogger'))().log;//singleton
const migrations = {
@@ -24,7 +23,7 @@ class ConnManager {
}
async init(config) {
this.config = configManager.config;
this.config = config;
this._pool = {};
const force = null;//(config.branch == 'development' ? 'last' : null);

View File

@@ -14,7 +14,7 @@ async function init() {
//logger
const appLogger = new (require('./core/AppLogger'))();//singleton
await appLogger.init();
await appLogger.init(config);
const log = appLogger.log;
//dirs
@@ -37,7 +37,7 @@ async function init() {
//connections
const connManager = new (require('./db/ConnManager'))();//singleton
await connManager.init();
await connManager.init(config);
}
async function main() {