Setup eslint and enforce rules
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import {Inject, Singleton} from "../../di";
|
||||
import {DatabaseService} from "../DatabaseService";
|
||||
import {PostgresConnection} from "../connection/PostgresConnection";
|
||||
import {ErrorWithContext} from "../../util";
|
||||
import {Unit} from "../../lifecycle/Unit";
|
||||
import {Config} from "../../service/Config";
|
||||
import {Logging} from "../../service/Logging";
|
||||
import {Inject, Singleton} from '../../di'
|
||||
import {DatabaseService} from '../DatabaseService'
|
||||
import {PostgresConnection} from '../connection/PostgresConnection'
|
||||
import {ErrorWithContext} from '../../util'
|
||||
import {Unit} from '../../lifecycle/Unit'
|
||||
import {Config} from '../../service/Config'
|
||||
import {Logging} from '../../service/Logging'
|
||||
|
||||
/**
|
||||
* Application unit responsible for loading and creating database connections from config.
|
||||
@@ -24,12 +24,15 @@ export class Database extends Unit {
|
||||
* Load the `database.connections` config and register Connection instances for each config.
|
||||
* Automatically initializes the connections.
|
||||
*/
|
||||
public async up() {
|
||||
public async up(): Promise<void> {
|
||||
const connections = this.config.get('database.connections')
|
||||
const promises = []
|
||||
|
||||
for ( const key in connections ) {
|
||||
if ( !connections.hasOwnProperty(key) ) continue
|
||||
if ( !Object.prototype.hasOwnProperty.call(connections, key) ) {
|
||||
continue
|
||||
}
|
||||
|
||||
const config = connections[key]
|
||||
|
||||
this.logging.info(`Initializing database connection: ${key}`)
|
||||
@@ -55,7 +58,7 @@ export class Database extends Unit {
|
||||
/**
|
||||
* Close the configured connections cleanly before exit.
|
||||
*/
|
||||
public async down() {
|
||||
public async down(): Promise<void> {
|
||||
await Promise.all(this.dbService.names()
|
||||
.map(name => this.dbService.get(name).close()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user