Skip to content

Commit

Permalink
refactor(mwcp): use MConfig instead of Config
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Apr 5, 2024
1 parent ac0d8dd commit 29ac025
Show file tree
Hide file tree
Showing 35 changed files with 21 additions and 61 deletions.
8 changes: 4 additions & 4 deletions packages/midway-component-kmore/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import assert from 'node:assert'

import {
App,
Config as _Config,
Configuration,
ILifeCycle,
ILogger,
Expand All @@ -19,6 +18,7 @@ import { TraceInit } from '@mwcp/otel'
import {
Application,
IMidwayContainer,
MConfig,
RegisterDecoratorHandlerParam,
registerDecoratorHandler,
registerMiddleware,
Expand Down Expand Up @@ -62,10 +62,10 @@ export class AutoConfiguration implements ILifeCycle {

@Logger() protected readonly logger: ILogger

@_Config(ConfigKey.config) readonly config: Config
@_Config() readonly kmoreSourceConfig: KmoreSourceConfig
@MConfig(ConfigKey.config) readonly config: Config
@MConfig() readonly kmoreSourceConfig: KmoreSourceConfig

@_Config(ConfigKey.propagationConfig) protected readonly propagationConfig: KmorePropagationConfig
@MConfig(ConfigKey.propagationConfig) protected readonly propagationConfig: KmorePropagationConfig

@Inject() readonly dbSManager: DbSourceManager

Expand Down
5 changes: 2 additions & 3 deletions packages/midway-component-kmore/src/lib/db-source-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import assert from 'node:assert'

import {
Config as _Config,
Init,
Inject,
Logger as _Logger,
Expand All @@ -21,7 +20,7 @@ import {
TraceInit,
TraceService,
} from '@mwcp/otel'
import type { Context } from '@mwcp/share'
import { Context, MConfig } from '@mwcp/share'
import {
EventCallbacks,
Kmore,
Expand Down Expand Up @@ -49,7 +48,7 @@ import { ConfigKey, KmoreSourceConfig, DbConfig } from './types.js'
export class DbSourceManager<SourceName extends string = string, D = unknown, Ctx extends Context = Context>
extends AbstractDbSourceManager<SourceName, D, Ctx> {

@_Config(ConfigKey.config) private readonly sourceConfig: KmoreSourceConfig<SourceName>
@MConfig(ConfigKey.config) private readonly sourceConfig: KmoreSourceConfig<SourceName>

@_Logger() private readonly logger: ILogger

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Controller,
Get,
Inject,
Param,
} from '@midwayjs/core'
import type { Context } from '@mwcp/share'
import { Context, MConfig } from '@mwcp/share'

import {
ConfigKey,
Expand All @@ -20,7 +19,7 @@ import { Db, Db2, UserDTO, UserExtDTO } from '../../../test.model.js'
@Controller('/user')
export class UserController {

@_Config(ConfigKey.middlewareConfig) protected readonly mwConfig: MiddlewareConfig
@MConfig(ConfigKey.middlewareConfig) protected readonly mwConfig: MiddlewareConfig

@Inject() readonly ctx: Context
@Inject() dbManager: DbManager<'master', Db>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Controller,
Get,
Init,
Inject,
Param,
} from '@midwayjs/core'
import type { Context } from '@mwcp/share'
import { Context } from '@mwcp/share'
import { KmoreTransaction } from 'kmore'

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Controller,
Get,
Init,
Inject,
Param,
} from '@midwayjs/core'
import type { Context } from '@mwcp/share'
import { Context } from '@mwcp/share'
import { KmoreTransaction } from 'kmore'

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Controller,
Get,
Init,
Inject,
} from '@midwayjs/core'
import type { Context } from '@mwcp/share'
import { Context, MConfig } from '@mwcp/share'

import {
ConfigKey,
Expand All @@ -21,7 +20,7 @@ import { Db, UserDTO } from '../../../test.model.js'
@Controller('/user')
export class UserPagingController {

@_Config(ConfigKey.middlewareConfig) protected readonly mwConfig: MiddlewareConfig
@MConfig(ConfigKey.middlewareConfig) protected readonly mwConfig: MiddlewareConfig

@Inject() readonly ctx: Context
@Inject() dbManager: DbManager<'master', Db>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {
Config as _Config,
Controller,
Get,
Inject,
} from '@midwayjs/core'
import type { Context } from '@mwcp/share'
import { Context } from '@mwcp/share'

import { apiPrefix, apiRoute } from '../api-route.js'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Inject,
InjectClient,
} from '@midwayjs/core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Init,
Inject,
} from '@midwayjs/core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Init,
Inject,
} from '@midwayjs/core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Config as _Config,
Controller,
Get,
Inject,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Inject,
} from '@midwayjs/core'
import { Inject } from '@midwayjs/core'
import { CacheConfigKey, initCacheManagerOptions } from '@mwcp/cache'

import { Transactional } from '../../../../../dist/index.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Init,
Inject,
} from '@midwayjs/core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Controller,
Get,
Init,
Inject,
Param,
} from '@midwayjs/core'
import type { Context } from '@mwcp/share'
import { Context } from '@mwcp/share'
import { KmoreTransaction } from 'kmore'

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Controller,
Get,
Init,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert'

import {
Config as _Config,
Controller,
Get,
Inject,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Init,
Inject,
Provide,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert'

import {
Config as _Config,
Controller,
Get,
Inject,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Init,
Inject,
} from '@midwayjs/core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Controller,
Get,
Init,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Controller,
Get,
Init,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Init,
Inject,
} from '@midwayjs/core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Config as _Config,
Controller,
Get,
Inject,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Inject,
} from '@midwayjs/core'
import { Inject } from '@midwayjs/core'


import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Init,
Inject,
} from '@midwayjs/core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Config as _Config,
Controller,
Get,
Inject,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
Config as _Config,
Controller,
Get,
Inject,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Inject,
} from '@midwayjs/core'
import { Inject } from '@midwayjs/core'

import { Transactional, TrxPropagateOptions } from '../../../../../dist/index.js'
import type { UserDTO } from '../../../../test.model.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Init,
Inject,
} from '@midwayjs/core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Init,
Inject,
} from '@midwayjs/core'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert'

import {
Config as _Config,
Controller,
Get,
Inject,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Init,
Inject,
Singleton,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Init,
Inject,
Singleton,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import assert from 'node:assert/strict'

import {
Config as _Config,
Controller,
Get,
Inject,
Param,
} from '@midwayjs/core'
import type { Context } from '@mwcp/share'
import { Context, MConfig } from '@mwcp/share'

import {
ConfigKey,
Expand All @@ -20,7 +19,7 @@ import { Db, Db2, UserDTO, UserExtDTO } from '../../../test.model.js'
@Controller('/user2')
export class User2Controller {

@_Config(ConfigKey.middlewareConfig) protected readonly mwConfig: MiddlewareConfig
@MConfig(ConfigKey.middlewareConfig) protected readonly mwConfig: MiddlewareConfig

@Inject() readonly ctx: Context
@Inject() dbManager: DbManager<'master', Db>
Expand Down
Loading

0 comments on commit 29ac025

Please sign in to comment.