跳到主要内容
版本:Next

@midwayjs/core

Index

Classes

Enumerations

Functions

Interfaces

Namespaces

Type Aliases

Variables

Type Aliases

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

DataSourceManagerConfigOption

DataSourceManagerConfigOption<OPTIONS, ENTITY_CONFIG_KEY>: { dataSource?: {}; default?: OPTIONS; defaultDataSourceName?: string } & CreateDataSourceInstanceOptions

Type parameters

  • OPTIONS
  • ENTITY_CONFIG_KEY: string = entities

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

GroupModeType

GroupModeType: one | multi

HandlerFunction

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

HttpClientMimeType

HttpClientMimeType: text | json | undefined

IApplicationContext

IApplicationContext: IMidwayContainer
@deprecated

IMidwayApplication

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

Type parameters

IMidwayContext

IMidwayContext<FrameworkContext>: Context & FrameworkContext

Type parameters

  • FrameworkContext = unknown

IMidwayLogger

IMidwayLogger: ILogger
@deprecated

IgnoreMatcher

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

Type parameters

  • CTX

KoaLikeCustomParamDecorator

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

Type parameters

  • T = unknown

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>

ObjectContext

ObjectContext: { originName?: string }

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

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 = 'common:all_value_key'

constAPPLICATION_CONTEXT_KEY

APPLICATION_CONTEXT_KEY: __midway_application_context__ = '__midway_application_context__'

constAPPLICATION_KEY

APPLICATION_KEY: __midway_framework_app__ = '__midway_framework_app__'

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'

constCONFIG_KEY

CONFIG_KEY: config = 'config'

constCONTAINER_OBJ_SCOPE

CONTAINER_OBJ_SCOPE: _obj_scope = '_obj_scope'

constCONTROLLER_KEY

CONTROLLER_KEY: web:controller = 'web:controller'

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'

constHSF_KEY

HSF_KEY: rpc:hsf = 'rpc:hsf'

constHTTP_SERVER_KEY

HTTP_SERVER_KEY: _midway_http_server = '_midway_http_server'

constIGNORE_PATTERN

IGNORE_PATTERN: string[] = ...

constINJECT_CLASS_KEY_PREFIX

INJECT_CLASS_KEY_PREFIX: INJECTION_CLASS_META_DATA = 'INJECTION_CLASS_META_DATA'

constINJECT_CUSTOM_METHOD

INJECT_CUSTOM_METHOD: inject_custom_method = 'inject_custom_method'

constINJECT_CUSTOM_PARAM

INJECT_CUSTOM_PARAM: inject_custom_param = 'inject_custom_param'

constINJECT_CUSTOM_PROPERTY

INJECT_CUSTOM_PROPERTY: inject_custom_property = 'inject_custom_property'

constINJECT_TAG

INJECT_TAG: inject = 'inject'

constKEYS

KEYS: { AROUND_ELEMENT: string; ASPECT_ELEMENT: string; ASYNC_ATTRIBUTE: string; AUTOWIRE_ATTRIBUTE: string; CONFIGURATION_ELEMENT: string; CONSTRUCTOR_ARG_ELEMENT: string; DIRECT_ATTRIBUTE: string; ENTRY_ELEMENT: string; EXECUTE_ATTRIBUTE: string; EXPRESSION_ATTRIBUTE: string; EXTERNAL_ATTRIBUTE: string; ID_ATTRIBUTE: string; IMPORT_ELEMENT: string; JSON_ELEMENT: string; KEY_ATTRIBUTE: string; LIST_ELEMENT: string; MAP_ELEMENT: string; NAME_ATTRIBUTE: string; OBJECTS_ELEMENT: string; OBJECT_ATTRIBUTE: string; OBJECT_ELEMENT: string; PATH_ATTRIBUTE: string; PROPERTY_ELEMENT: string; PROPS_ELEMENT: string; PROP_ELEMENT: string; REF_ATTRIBUTE: string; REF_ELEMENT: string; RESOURCE_ATTRIBUTE: string; SCOPE_ATTRIBUTE: string; SET_ELEMENT: string; TYPE_ATTRIBUTE: string; VALUE_ATTRIBUTE: string; VALUE_ELEMENT: string } = ...

静态参数

constLIFECYCLE_IDENTIFIER_PREFIX

LIFECYCLE_IDENTIFIER_PREFIX: __lifecycle__ = '__lifecycle__'

constLOGGER_KEY

LOGGER_KEY: logger = 'logger'

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'

constNAMED_TAG

NAMED_TAG: named = 'named'

constOBJ_DEF_CLS

OBJ_DEF_CLS: injection:object_definition_class = 'injection:object_definition_class'

constPIPELINE_IDENTIFIER

PIPELINE_IDENTIFIER: __pipeline_identifier__ = '__pipeline_identifier__'

constPLUGIN_KEY

PLUGIN_KEY: plugin = 'plugin'

constPRELOAD_MODULE_KEY

PRELOAD_MODULE_KEY: INJECTION_PRELOAD_MODULE_KEY = 'INJECTION_PRELOAD_MODULE_KEY'

constPRIVATE_META_DATA_KEY

PRIVATE_META_DATA_KEY: __midway_private_meta_data__ = '__midway_private_meta_data__'

constPathFileUtil

PathFileUtil: { 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_OBJ_CTX_KEY

REQUEST_OBJ_CTX_KEY: _req_ctx = '_req_ctx'

constRPC_DUBBO_KEY

RPC_DUBBO_KEY: rpc:dubbo = 'rpc:dubbo'

constRPC_GRPC_KEY

RPC_GRPC_KEY: rpc:grpc = 'rpc:grpc'

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'

constSERVERLESS_FUNC_KEY

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

constSINGLETON_CONTAINER_CTX

SINGLETON_CONTAINER_CTX: { _MAIN_CTX_: boolean } = ...

constTAGGED_CLS

TAGGED_CLS: injection:tagged_class = 'injection:tagged_class'

constTAGGED_FUN

TAGGED_FUN: injection:tagged_function = 'injection:tagged_function'

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) => 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; UnauthorizedError: typeof UnauthorizedError; UnprocessableEntityError: typeof UnprocessableEntityError; UnsupportedMediaTypeError: typeof UnsupportedMediaTypeError } = ...