Skip to content

Commit

Permalink
Update logger imports and parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
MXPOL committed Feb 11, 2024
1 parent 801a9ca commit b2cfc82
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions apps/velo-external-db/src/storage/factory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Logger } from '@wix-velo/external-db-logger'
import { ILogger } from '@wix-velo/external-db-logger'
import { DatabaseFactoryResponse } from '@wix-velo/velo-external-db-commons'

export const engineConnectorFor = async(_type: string, config: any, logger?: Logger): Promise<DatabaseFactoryResponse> => {
export const engineConnectorFor = async(_type: string, config: any, logger?: ILogger): Promise<DatabaseFactoryResponse> => {
const type = _type || ''
switch ( type.toLowerCase() ) {
case 'postgres': {
Expand Down
3 changes: 1 addition & 2 deletions libs/external-db-mysql/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { MySqlConfigValidator } from './mysql_config_validator'
import { DatabaseFactoryResponse, DbConnector } from '@wix-velo/velo-external-db-commons'
import init from './connection_provider'
import { MySqlConfig } from './types'
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')
Expand All @@ -25,7 +24,7 @@ export class MySqlConnector extends DbConnector {
}
}

export const mySqlFactory = async(config: MySqlConfig, logger: Logger, options: any): Promise<DatabaseFactoryResponse> => {
export const mySqlFactory = async(config: MySqlConfig, 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
16 changes: 8 additions & 8 deletions libs/velo-external-db-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import QueryValidator from './converters/query_validator'
import SchemaAwareDataService from './service/schema_aware_data'
import { initServices, createRouter } from './router'
import { DbConnector } from '@wix-velo/velo-external-db-commons'
import { Logger } from '@wix-velo/external-db-logger'
import { ILogger } from '@wix-velo/external-db-ILogger'
import { DataHooks, ExternalDbRouterConfig, Hooks, SchemaHooks, ServiceContext } from './types'
import ItemTransformer = require('./converters/item_transformer')
import { RoleAuthorizationService } from '@wix-velo/external-db-security'
Expand All @@ -23,7 +23,7 @@ import { decodeBase64 } from './utils/base64_utils'
interface ExternalDbRouterConstructorParams {
connector: DbConnector;
config: ExternalDbRouterConfig;
logger?: Logger;
ILogger?: ILogger;
hooks: {schemaHooks?: SchemaHooks, dataHooks?: DataHooks};
}

Expand All @@ -44,11 +44,11 @@ export class ExternalDbRouter {
cleanup: ConnectionCleanUp
router: Router
config: ExternalDbRouterConfig
logger?: Logger
constructor({ connector, config, hooks, logger }: ExternalDbRouterConstructorParams) {
ILogger?: ILogger
constructor({ connector, config, hooks, ILogger }: ExternalDbRouterConstructorParams) {
this.isInitialized(connector)
this.connector = connector
this.logger = logger
this.ILogger = ILogger
this.configValidator = new ConfigValidator(connector.configValidator,
new AuthorizationConfigValidator(config.authorization),
new CommonConfigValidator({ vendor: config.vendor, type: config.adapterType, jwtPublicKey: config.jwtPublicKey, appDefId: config.appDefId },
Expand All @@ -67,17 +67,17 @@ export class ExternalDbRouter {
this.roleAuthorizationService = new RoleAuthorizationService(config.authorization?.roleConfig?.collectionPermissions)
this.cleanup = connector.cleanup

initServices(this.schemaAwareDataService, this.schemaService, this.operationService, this.configValidator, { ...config, type: connector.type }, this.filterTransformer, this.aggregationTransformer, this.roleAuthorizationService, hooks, logger)
initServices(this.schemaAwareDataService, this.schemaService, this.operationService, this.configValidator, { ...config, type: connector.type }, this.filterTransformer, this.aggregationTransformer, this.roleAuthorizationService, hooks, ILogger)
this.router = createRouter()
}

reloadHooks(hooks?: Hooks) {
initServices(this.schemaAwareDataService, this.schemaService, this.operationService, this.configValidator, { ...this.config, type: this.connector.type }, this.filterTransformer, this.aggregationTransformer, this.roleAuthorizationService, hooks || {}, this.logger)
initServices(this.schemaAwareDataService, this.schemaService, this.operationService, this.configValidator, { ...this.config, type: this.connector.type }, this.filterTransformer, this.aggregationTransformer, this.roleAuthorizationService, hooks || {}, this.ILogger)
}

isInitialized(connector: DbConnector) {
if (!connector.initialized) {
this.logger?.error('Connector must be initialized before being used')
this.ILogger?.error('Connector must be initialized before being used')
throw new Error('Connector must be initialized before being used')
}
}
Expand Down

0 comments on commit b2cfc82

Please sign in to comment.