Skip to content

Commit

Permalink
Open database in application not in core
Browse files Browse the repository at this point in the history
Closes: #1282

PR-UR: #1381
  • Loading branch information
tshemsedinov committed Nov 4, 2020
1 parent 9dbae5d commit 5bde5fd
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 15 deletions.
1 change: 0 additions & 1 deletion lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class Application extends events.EventEmitter {
this.Application = Application;
this.Error = Error;
this.cert = null;
this.db = null;
this.auth = null;
this.logger = null;
}
Expand Down
6 changes: 5 additions & 1 deletion lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ class Auth {
this.characters = characters;
this.secret = secret;
this.length = length;
this.db = application.db;
this.db = null;
}

init(database) {
this.db = database;
}

save(session) {
Expand Down
2 changes: 0 additions & 2 deletions lib/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const application = require('./application.js');

const { Config } = require('@metarhia/config');
const { Logger } = require('metalog');
const { Database } = require('metasql');
const { Server } = require('metacom');
const { Channel } = require('./channel.js');
const { Auth } = require('./auth.js');
Expand Down Expand Up @@ -45,7 +44,6 @@ const { Console } = require('./console.js');
} catch {
if (threadId === 1) logger.error('Can not load TLS certificates');
}
application.db = new Database({ ...config.database, logger });

const { balancer, ports = [] } = config.server;
const servingThreads = ports.length + (balancer ? 1 : 0);
Expand Down
10 changes: 0 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"@metarhia/config": "^2.0.0-alpha.3",
"metacom": "0.1.0-alpha.9",
"metalog": "^3.0.0-alpha.0",
"metasql": "^0.3.0-alpha.0",
"metavm": "0.1.0",
"pg": "^8.4.2",
"ws": "^7.3.1"
Expand Down

0 comments on commit 5bde5fd

Please sign in to comment.