跳到主要内容
版本:Next

@midwayjs/core

Index

Classes

Enumerations

Functions

Interfaces

Namespaces

Type Aliases

Variables

Type Aliases

BaseDataSourceManagerConfigOption

BaseDataSourceManagerConfigOption<OPTIONS, ENTITY_CONFIG_KEY>: OPTIONS & { customDataSourceClass?: any; validateConnection?: boolean } & { [ key in ENTITY_CONFIG_KEY ]?: any[] }

Type parameters

  • OPTIONS: Record<string, any>
  • ENTITY_CONFIG_KEY: string = entities

ClassMiddleware

ClassMiddleware<CTX, R, N>: new (...args: any) => IMiddleware<CTX, R, N>

Type parameters

  • CTX
  • R
  • N

ClassType

ClassType<T>: new (...args: any[]) => T

Type parameters

  • T = any

CommonFilterUnion

CommonFilterUnion<CTX, R, N>: new (...args: any) => IFilter<CTX, R, N> | new (...args: any) => IFilter<CTX, R, N>[]

Type parameters

  • CTX
  • R
  • N

CommonGuardUnion

CommonGuardUnion<CTX>: new (...args: any) => IGuard<CTX> | new (...args: any) => IGuard<CTX>[]

Type parameters

  • CTX = unknown

CommonMiddleware

CommonMiddleware<CTX, R, N>: ClassMiddleware<CTX, R, N> | FunctionMiddleware<CTX, R, N> | CompositionMiddleware<CTX, R, N>

Type parameters

  • CTX
  • R
  • N

CommonMiddlewareUnion

CommonMiddlewareUnion<CTX, R, N>: CommonMiddleware<CTX, R, N> | CommonMiddleware<CTX, R, N>[]

Type parameters

  • CTX
  • R
  • N

CompositionMiddleware

CompositionMiddleware<CTX, R, N>: { middleware: ClassMiddleware<CTX, R, N>; name?: string; options: any }

Type parameters

  • CTX
  • R
  • N

ConsumerRunConfig

ConsumerRunConfig: { autoCommit?: boolean; autoCommitInterval?: number | null; autoCommitThreshold?: number | null; eachBatchAutoResolve?: boolean; partitionsConsumedConcurrently?: number }

ConsumerSubscribeTopic

ConsumerSubscribeTopic: { fromBeginning?: boolean }
@deprecated

Replaced by ConsumerSubscribeTopics

ConsumerSubscribeTopics

ConsumerSubscribeTopics: { fromBeginning?: boolean }

CreateDataSourceInstanceOptions

CreateDataSourceInstanceOptions: { cacheInstance?: boolean; validateConnection?: boolean }

CustomParamDecorator

Type parameters

  • T = unknown

DynamicRouterInfo

DynamicRouterInfo: Omit<RouterInfo, id | method | controllerId | controllerMiddleware | responseMetadata>

ExpressLikeCustomParamDecorator

ExpressLikeCustomParamDecorator<T>: (req: any, res: any) => T | Promise<T>

Type parameters

  • T = unknown

FileConfigOption

FileConfigOption<T, K>: K extends keyof ConfigType<T> ? Pick<ConfigType<T>, K> : ConfigType<T>

Get definition from config


Type parameters

  • T
  • K = unknown

FunctionMiddleware

FunctionMiddleware<CTX, R, N>: N extends true ? (req: CTX, res: R, next: N) => any : (context: CTX, next: R, options?: any) => any

Type parameters

  • CTX
  • R
  • N = unknown

FunctionalConfigurationOptions

FunctionalConfigurationOptions: InjectionConfigurationOptions & ILifeCycle

HandlerFunction

HandlerFunction: (key: string, meta: any, instance: any) => any

HttpClientMimeType

HttpClientMimeType: text | json | undefined

IMidwayApplication

IMidwayApplication<T, FrameworkApplication>: IMidwayBaseApplication<T> & FrameworkApplication

Type parameters

IMidwayContext

IMidwayContext<FrameworkContext>: Context & FrameworkContext

Type parameters

  • FrameworkContext = unknown

IgnoreMatcher

IgnoreMatcher<CTX>: string | RegExp | (ctx: CTX) => boolean

Type parameters

  • CTX

KoaLikeCustomParamDecorator

KoaLikeCustomParamDecorator<T>: (ctx: IMidwayContext) => T | Promise<T>

Type parameters

  • T = unknown

LoadBalancerType

LoadBalancerType: typeof LoadBalancerType[keyof typeof LoadBalancerType]

MatchPattern

MatchPattern<CtxOrReq, Res>: (ctxOrReq: CtxOrReq, res: Res) => boolean | string | string[] | boolean

Type parameters

  • CtxOrReq = any
  • Res = any

MethodHandlerFunction

MethodHandlerFunction: (options: { metadata: any; propertyName: string; target: new (...args: any) => any }) => IMethodAspect

MiddlewareParamArray

MiddlewareParamArray: (string | any)[]

MiddlewareRespond

MiddlewareRespond<CTX, R, N>: (context: CTX, nextOrRes?: N extends true ? R : NextFunction, next?: N) => Promise<any>

Type parameters

  • CTX
  • R
  • N

ModuleLoadType

ModuleLoadType: commonjs | esm

NextFunction

NextFunction: () => Promise<any>

ObjectIdentifier

ObjectIdentifier: string | Symbol

ParameterHandlerFunction

ParameterHandlerFunction: (options: { metadata: any; originArgs: any[]; originParamType: any; parameterIndex: number; propertyName: string; target: new (...args: any) => any }) => any

PipeTransformFunction

PipeTransformFunction<T, R>: (value: T) => R

Type parameters

  • T = any
  • R = any

PipeUnionTransform

PipeUnionTransform<T, R>: PipeTransform<T, R> | new (...args: any) => PipeTransform<T, R> | PipeTransformFunction<T, R>

Type parameters

  • T = any
  • R = any

PowerPartial

PowerPartial<T>: { [ U in keyof T ]?: T[U] extends {} ? PowerPartial<T[U]> : T[U] }

Type parameters

  • T

ResOrMessage

ResOrMessage: string | { message: string } | undefined

ServiceDiscoveryHealthCheckOptions

健康检查配置联合类型

ServiceDiscoveryHealthCheckType

ServiceDiscoveryHealthCheckType: typeof ServiceDiscoveryHealthCheckType[keyof typeof ServiceDiscoveryHealthCheckType]

ServiceFactoryConfigOption

ServiceFactoryConfigOption<OPTIONS>: { client?: PowerPartial<OPTIONS>; clientPriority?: {}; clients?: {}; default?: PowerPartial<OPTIONS>; defaultClientName?: string }

Type parameters

  • OPTIONS

WithFn

WithFn<T>: { [ K in keyof T ]: T[K] extends (...args: infer P) => infer R ? (fn: (...args: P) => R) => void : T[K] }

Utility type that adds a fn parameter to each method in the input type T, transforming the original method's parameter types and return type into a function type.

@example
// Input:
interface MyInterface {
method1(a: string, b: number): boolean;
method2(x: Foo, y: Bar): void;
}

// Output:
interface MyInterfaceWithFn {
method1(fn: (a: string, b: number) => boolean): void;
method2(fn: (x: Foo, y: Bar) => void): void;
}

Type parameters

  • T

WithoutFn

WithoutFn<T>: { [ K in keyof T ]: T[K] extends (arg: any, ...args: any[]) => any ? (...args: Parameters<T[K]>) => ReturnType<T[K]> : T[K] }

Transform an object type T with methods that have function-type parameters to a new object type with the same methods, but with the parameters extracted as separate properties.


Type parameters

  • T

Writable

Writable<T>: { -readonly [ P in keyof T ]: T[P] }

Make object property writeable


Type parameters

  • T

Variables

constALL

ALL: common:all_value_key = ALL_VALUE_KEY
@deprecated

Use ALL_VALUE_KEY instead

constALL_VALUE_KEY

ALL_VALUE_KEY: common:all_value_key = 'common:all_value_key'

constAPPLICATION_CONTEXT_KEY

APPLICATION_CONTEXT_KEY: common:application_context = 'common:application_context'

constAPPLICATION_KEY

APPLICATION_KEY: common:application = 'common:application'

constASPECT_KEY

ASPECT_KEY: common:aspect = 'common:aspect'

constASYNC_CONTEXT_KEY

ASYNC_CONTEXT_KEY: typeof ASYNC_CONTEXT_KEY = ...

constASYNC_CONTEXT_MANAGER_KEY

ASYNC_CONTEXT_MANAGER_KEY: MIDWAY_ASYNC_CONTEXT_MANAGER_KEY = 'MIDWAY_ASYNC_CONTEXT_MANAGER_KEY'

constASYNC_ROOT_CONTEXT

ASYNC_ROOT_CONTEXT: AsyncContext = ...

The root context is used as the default parent context when there is no active context

constCATCH_KEY

CATCH_KEY: common:catch = 'common:catch'

constCLASS_KEY_CONSTRUCTOR

CLASS_KEY_CONSTRUCTOR: midway:class_key_constructor = 'midway:class_key_constructor'

constCONFIGURATION_KEY

CONFIGURATION_KEY: common:configuration = 'common:configuration'

constCONFIGURATION_OBJECT_KEY

CONFIGURATION_OBJECT_KEY: common:configuration_object = 'common:configuration_object'

constCONFIG_KEY

CONFIG_KEY: config = 'config'

constCONSTRUCTOR_INJECT_KEY

CONSTRUCTOR_INJECT_KEY: common:constructor_inject = 'common:constructor_inject'

constCONTAINER_OBJ_SCOPE

CONTAINER_OBJ_SCOPE: _obj_scope = '_obj_scope'

constCONTROLLER_KEY

CONTROLLER_KEY: web:controller = 'web:controller'

constCUSTOM_METHOD_INJECT_KEY

CUSTOM_METHOD_INJECT_KEY: common:custom_method_inject = 'common:custom_method_inject'

constCUSTOM_PARAM_INJECT_KEY

CUSTOM_PARAM_INJECT_KEY: common:custom_param_inject = 'common:custom_param_inject'

constCUSTOM_PROPERTY_INJECT_KEY

CUSTOM_PROPERTY_INJECT_KEY: common:custom_property_inject = 'common:custom_property_inject'

constDEFAULT_PATTERN

DEFAULT_PATTERN: string[] = ...

constDEFAULT_PRIORITY

DEFAULT_PRIORITY: { L1: string; L2: string; L3: string } = ...

constFACTORY_SERVICE_CLIENT_KEY

FACTORY_SERVICE_CLIENT_KEY: common:service_factory:client = 'common:service_factory:client'

constFORMAT

FORMAT: { CRONTAB: { EVERY_DAY: string; EVERY_DAY_ONE_FIFTEEN: string; EVERY_DAY_ZERO_FIFTEEN: string; EVERY_HOUR: string; EVERY_MINUTE: string; EVERY_PER_10_MINUTE: string; EVERY_PER_10_SECOND: string; EVERY_PER_30_MINUTE: string; EVERY_PER_30_SECOND: string; EVERY_PER_5_MINUTE: string; EVERY_PER_5_SECOND: string; EVERY_SECOND: string }; MS: { ONE_DAY: number; ONE_HOUR: number; ONE_MINUTE: number; ONE_SECOND: number; ONE_WEEK: number; ONE_YEAR: number } } = ...

constFRAMEWORK_KEY

FRAMEWORK_KEY: common:framework = 'common:framework'

constFUNCTION_INJECT_KEY

FUNCTION_INJECT_KEY: midway:function_inject_key = 'midway:function_inject_key'

constFUNC_KEY

FUNC_KEY: faas:func = 'faas:func'

constFileUtils

FileUtils: { exists: (p: any) => Promise<boolean> } = ...

constFrameworkErrorEnum

FrameworkErrorEnum: ConvertString<{ CODE_INVOKE_TIMEOUT: 10019; COMMON: 10001; DEFINITION_NOT_FOUND: 10003; DUPLICATE_CLASS_NAME: 10015; DUPLICATE_CONTROLLER_PREFIX_OPTIONS: 10016; DUPLICATE_ROUTER: 10008; EMPTY_VALUE: 10022; FEATURE_NOT_IMPLEMENTED: 10004; FEATURE_NO_LONGER_SUPPORTED: 10004; INCONSISTENT_VERSION: 10013; INVALID_CONFIG: 10014; INVALID_CONFIG_PROPERTY: 10021; INVOKE_METHOD_FORBIDDEN: 10018; MAIN_FRAMEWORK_MISSING: 10020; MISSING_CONFIG: 10006; MISSING_IMPORTS: 10011; MISSING_RESOLVER: 10007; PARAM_TYPE: 10002; RETRY_OVER_MAX_TIME: 10017; SINGLETON_INJECT_REQUEST: 10010; UNKNOWN: 10000; USE_WRONG_METHOD: 10009; UTIL_HTTP_TIMEOUT: 10012 }, midway> = ...

constGUARD_KEY

GUARD_KEY: common:guard = 'common:guard'

constHTTP_SERVER_KEY

HTTP_SERVER_KEY: _midway_http_server = '_midway_http_server'

constIGNORE_PATTERN

IGNORE_PATTERN: string[] = ...

constINJECT_CUSTOM_METHOD

INJECT_CUSTOM_METHOD: common:custom_method_inject = CUSTOM_METHOD_INJECT_KEY
@deprecated

Use CUSTOM_METHOD_INJECT_KEY instead

constINJECT_CUSTOM_PARAM

INJECT_CUSTOM_PARAM: common:custom_param_inject = CUSTOM_PARAM_INJECT_KEY
@deprecated

Use CUSTOM_PARAM_INJECT_KEY instead

constINJECT_CUSTOM_PROPERTY

INJECT_CUSTOM_PROPERTY: common:custom_property_inject = CUSTOM_PROPERTY_INJECT_KEY
@deprecated

Use CUSTOM_PROPERTY_INJECT_KEY instead

constINJECT_TAG

INJECT_TAG: common:property_inject = PROPERTY_INJECT_KEY
@deprecated

Use PROPERTY_INJECT_KEY instead

constKEYS

KEYS: { REF_CUSTOM: string; REF_ELEMENT: string } = ...

静态参数

constLOGGER_KEY

LOGGER_KEY: logger = 'logger'

constLoadBalancerType

LoadBalancerType: { RANDOM: random; ROUND_ROBIN: roundRobin } = ...

负载均衡策略类型

constMAIN_APPLICATION_KEY

MAIN_APPLICATION_KEY: common:main_application = 'common:main_application'

constMAIN_MODULE_KEY

MAIN_MODULE_KEY: __main__ = '__main__'

constMATCH_KEY

MATCH_KEY: common:match = 'common:match'

constMIDWAY_LOGGER_WRITEABLE_DIR

MIDWAY_LOGGER_WRITEABLE_DIR: MIDWAY_LOGGER_WRITEABLE_DIR = 'MIDWAY_LOGGER_WRITEABLE_DIR'

constMOCK_KEY

MOCK_KEY: common:mock = 'common:mock'

constMODULE_TASK_KEY

MODULE_TASK_KEY: task:task = 'task:task'

constMODULE_TASK_METADATA

MODULE_TASK_METADATA: task:task:options = 'task:task:options'

constMODULE_TASK_QUEUE_KEY

MODULE_TASK_QUEUE_KEY: task:task:queue = 'task:task:queue'

constMODULE_TASK_QUEUE_OPTIONS

MODULE_TASK_QUEUE_OPTIONS: task:task:queue:options = 'task:task:queue:options'

constMODULE_TASK_TASK_LOCAL_KEY

MODULE_TASK_TASK_LOCAL_KEY: task:task:task_local = 'task:task:task_local'

constMODULE_TASK_TASK_LOCAL_OPTIONS

MODULE_TASK_TASK_LOCAL_OPTIONS: task:task:task_local:options = 'task:task:task_local:options'

constMS_CONSUMER_KEY

MS_CONSUMER_KEY: ms:consumer = 'ms:consumer'

constMS_DUBBO_METHOD_KEY

MS_DUBBO_METHOD_KEY: ms:dubbo:method = 'ms:dubbo:method'

constMS_GRPC_METHOD_KEY

MS_GRPC_METHOD_KEY: ms:grpc:method = 'ms:grpc:method'

constMS_HSF_METHOD_KEY

MS_HSF_METHOD_KEY: ms:hsf:method = 'ms:hsf:method'

constMS_PRODUCER_KEY

MS_PRODUCER_KEY: ms:producer = 'ms:producer'

constMS_PROVIDER_KEY

MS_PROVIDER_KEY: ms:provider = 'ms:provider'

constNetworkUtils

NetworkUtils: { getHostname: () => string; getIpv4Address: () => string; getIpv6Address: () => string } = ...

constOBJECT_DEFINITION_KEY

OBJECT_DEFINITION_KEY: common:object_definition = 'common:object_definition'

constOBJ_DEF_CLS

OBJ_DEF_CLS: common:object_definition = OBJECT_DEFINITION_KEY
@deprecated

Use OBJECT_DEFINITION_KEY instead

constPLUGIN_KEY

PLUGIN_KEY: plugin = 'plugin'

constPRE_START_MODULE_KEY

PRE_START_MODULE_KEY: common:pre_start_module = 'common:pre_start_module'

constPROPERTY_INJECT_KEY

PROPERTY_INJECT_KEY: common:property_inject = 'common:property_inject'

constPROVIDE_KEY

PROVIDE_KEY: common:provide = 'common:provide'

constPathFileUtils

PathFileUtils: { getFileContentSync: (filePath: any, encoding?: BufferEncoding) => any; isPath: (p: any) => boolean; isPathEqual: (one: string, two: string) => boolean } = ...

constPathToRegexpUtil

PathToRegexpUtil: { compile: <P>(str: string, options?: ParseOptions & TokensToFunctionOptions) => PathFunction<P>; match: <P>(str: Path, options?: ParseOptions & TokensToRegexpOptions & RegexpToFunctionOptions) => MatchFunction<P>; parse: (str: string, options?: ParseOptions) => Token[]; toRegexp: (path: Path, keys?: Key[], options?: TokensToRegexpOptions & ParseOptions) => RegExp } = ...

constREQUEST_CTX_KEY

REQUEST_CTX_KEY: ctx = 'ctx'

constREQUEST_CTX_LOGGER_CACHE_KEY

REQUEST_CTX_LOGGER_CACHE_KEY: _midway_ctx_logger_cache = '_midway_ctx_logger_cache'

constREQUEST_CTX_UNIQUE_KEY

REQUEST_CTX_UNIQUE_KEY: _midway_ctx_unique_key = '_midway_ctx_unique_key'

constREQUEST_OBJ_CTX_KEY

REQUEST_OBJ_CTX_KEY: _req_ctx = '_req_ctx'

constRequestMethod

RequestMethod: { ALL: string; DELETE: string; GET: string; HEAD: string; OPTIONS: string; PATCH: string; POST: string; PUT: string } = ...

constSCHEDULE_KEY

SCHEDULE_KEY: common:schedule = 'common:schedule'

constSCOPE_KEY

SCOPE_KEY: common:scope = 'common:scope'

constSERVERLESS_FUNC_KEY

SERVERLESS_FUNC_KEY: faas:serverless:function = 'faas:serverless:function'

constSINGLETON_CONTAINER_CTX

SINGLETON_CONTAINER_CTX: { _MAIN_CTX_: boolean } = ...

constServiceDiscoveryHealthCheckType

ServiceDiscoveryHealthCheckType: { CUSTOM: custom; HTTP: http; SELF: self; TCP: tcp; TTL: ttl } = ...

constTAGGED_CLS

TAGGED_CLS: common:provide = PROVIDE_KEY
@deprecated

Use PROVIDE_KEY instead

constTypes

Types: { isAsyncFunction: (value: any) => boolean; isClass: (fn: any) => boolean; isFunction: (value: any) => boolean; isGeneratorFunction: (value: any) => boolean; isMap: (value: any) => boolean; isNull: (value: any) => boolean; isNullOrUndefined: (value: any) => boolean; isNumber: (value: any) => boolean; isObject: (value: any) => boolean; isPlainObject: (obj: any) => any; isPromise: (value: any) => boolean; isProxy: (value: any) => boolean; isRegExp: (value: any) => boolean; isSet: (value: any) => boolean; isString: (value: any) => boolean; isUndefined: (value: any) => boolean } = ...

constUtils

Utils: { camelCase: (input: string) => string; generateRandomId: () => string; getParamNames: (func: any) => string[]; isTypeScriptEnvironment: () => boolean; pascalCase: (input: string) => string; randomUUID: (force?: boolean) => string; safeParse: (text: string, reviver?: (this: any, key: string, value: any) => any) => any; safeStringify: (value: any, replacer?: any, space?: string | number) => string; sleep: (sleepTime?: number, abortController?: AbortController) => Promise<void>; toAsyncFunction: <T>(method: T) => (...args: Parameters<T>) => Promise<ReturnType<T>> } = ...

constWEB_RESPONSE_CONTENT_TYPE

WEB_RESPONSE_CONTENT_TYPE: web:response_content_type = 'web:response_content_type'

constWEB_RESPONSE_HEADER

WEB_RESPONSE_HEADER: web:response_header = 'web:response_header'

constWEB_RESPONSE_HTTP_CODE

WEB_RESPONSE_HTTP_CODE: web:response_http_code = 'web:response_http_code'

constWEB_RESPONSE_KEY

WEB_RESPONSE_KEY: web:response = 'web:response'

constWEB_RESPONSE_REDIRECT

WEB_RESPONSE_REDIRECT: web:response_redirect = 'web:response_redirect'

constWEB_RESPONSE_RENDER

WEB_RESPONSE_RENDER: web:response_render = 'web:response_render'

constWEB_ROUTER_KEY

WEB_ROUTER_KEY: web:router = 'web:router'

constWEB_ROUTER_PARAM_KEY

WEB_ROUTER_PARAM_KEY: web:router_param = 'web:router_param'

constWS_CONTROLLER_KEY

WS_CONTROLLER_KEY: ws:controller = 'ws:controller'

constWS_EVENT_KEY

WS_EVENT_KEY: ws:event = 'ws:event'

consthttpError

httpError: { BadGatewayError: typeof BadGatewayError; BadRequestError: typeof BadRequestError; ConflictError: typeof ConflictError; ForbiddenError: typeof ForbiddenError; GatewayTimeoutError: typeof GatewayTimeoutError; GoneError: typeof GoneError; InternalServerErrorError: typeof InternalServerErrorError; NotAcceptableError: typeof NotAcceptableError; NotFoundError: typeof NotFoundError; NotImplementedError: typeof NotImplementedError; PayloadTooLargeError: typeof PayloadTooLargeError; RequestTimeoutError: typeof RequestTimeoutError; ServiceUnavailableError: typeof ServiceUnavailableError; TooManyRequestsError: typeof TooManyRequestsError; UnauthorizedError: typeof UnauthorizedError; UnprocessableEntityError: typeof UnprocessableEntityError; UnsupportedMediaTypeError: typeof UnsupportedMediaTypeError } = ...
Page Options