Skip to content

Commit

Permalink
Refactor logger imports and types
Browse files Browse the repository at this point in the history
  • Loading branch information
MXPOL committed Jan 25, 2024
1 parent 68b80ee commit 301a3aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions libs/external-db-mysql/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ export * as testResources from '../tests/e2e-testkit/mysql_resources'
import { MySqlConfigValidator } from './mysql_config_validator'
import { DatabaseFactoryResponse, DbConnector } from '@wix-velo/velo-external-db-commons'
import init from './connection_provider'
import { Logger } from '@wix-velo/external-db-logger'
import { ILogger } from '@wix-velo/external-db-logger'

export const driver = () => require('../tests/drivers/sql_filter_transformer_test_support')
export const opsDriver = () => require('../tests/drivers/db_operations_test_support')


export class MySqlConnector extends DbConnector {
constructor(logger: Logger) {
constructor(logger: ILogger) {
super(MySqlConfigValidator, init)
this.type = 'mysql'
this.logger = logger
}
}

export const mySqlFactory = async(config: any, logger: Logger, options: any): Promise<DatabaseFactoryResponse> => {
export const mySqlFactory = async(config: any, logger: ILogger, options: any): Promise<DatabaseFactoryResponse> => {
const connector = new MySqlConnector(logger)
const { connection, cleanup, ...providers } = await connector.initialize(config, options, logger)
return { connector, connection, providers, cleanup }
Expand Down
10 changes: 5 additions & 5 deletions libs/velo-external-db-commons/src/libs/db_connector.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { Logger } from '@wix-velo/external-db-logger'
import { ILogger } from '@wix-velo/external-db-logger'
import { ConnectionCleanUp, DbProviders, IConfigValidator, IDatabaseOperations, IDataProvider, ISchemaProvider } from '@wix-velo/velo-external-db-types'


export default class DbConnector {
initialized: boolean
configValidatorProvider: any
init: (config: any, option: any, logger?: Logger) => Promise<DbProviders<any>> | DbProviders<any>
init: (config: any, option: any, logger?: ILogger) => Promise<DbProviders<any>> | DbProviders<any>
dataProvider!: IDataProvider
schemaProvider!: ISchemaProvider
databaseOperations!: IDatabaseOperations
connection: any
cleanup!: ConnectionCleanUp
configValidator!: IConfigValidator
type!: string
logger?: Logger
logger?: ILogger
constructor(
configValidator: any,
init: (config: any, ...args: any) => Promise<DbProviders<any>> | DbProviders<any>,
Logger?: Logger
Logger?: ILogger
) {
this.initialized = false
this.configValidatorProvider = configValidator
this.logger = Logger
this.init = init
}

async initialize(config: any, options: any, logger?: Logger) {
async initialize(config: any, options: any, logger?: ILogger) {
const { dataProvider, schemaProvider, databaseOperations, connection, cleanup } = await this.init(config, options, logger)
this.dataProvider = dataProvider
this.schemaProvider = schemaProvider
Expand Down

0 comments on commit 301a3aa

Please sign in to comment.