跳到主要内容
版本:Next

IMidwayExpressApplication

Hierarchy

  • IMidwayApplication<Context, ExpressApplication>
    • IMidwayExpressApplication

Callable

  • IMidwayExpressApplication(req: IncomingMessage | Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: ServerResponse<IncomingMessage> | Response<any, Record<string, any>, number>): any
  • IMidwayExpressApplication(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>, number>, next: NextFunction): void

  • Express instance itself is a request handler, which could be invoked without third argument.

Index

Methods

addConfigObject

  • addConfigObject(obj: any): any
  • Add new value to current config

createAnonymousContext

  • createAnonymousContext(...args: any[]): Context
  • create a context with RequestContainer

createLogger

  • createLogger(name: string, options: MidwayLoggerOptions): ILogger
  • Create a logger by name and options

getAppDir

  • getAppDir(): string
  • Get a project root directory, without src or dist

getApplicationContext

  • getApplicationContext(): IMidwayContainer
  • Get global Midway IoC Container

getAttr

  • getAttr<T>(key: string): T
  • Get value from app attribute map


    Type parameters

    • T

getBaseDir

  • getBaseDir(): string
  • Get a base directory for project, with src or dist

getConfig

  • getConfig(key?: string): any
  • Get all configuration values or get the specified configuration through parameters

getCoreLogger

  • getCoreLogger(): ILogger
  • Get core logger

getEnv

  • getEnv(): string
  • Get a environment value, read from MIDWAY_SERVER_ENV

getFramework

  • get current related framework

getFrameworkType

  • @deprecated

    Get current framework type in MidwayFrameworkType enum

getLogger

  • getLogger(name?: string): ILogger
  • Get default logger object or get the specified logger through parameters

getMiddleware

  • getMiddleware<Response, NextFunction>(): ContextMiddlewareManager<Context, Response, NextFunction>
  • get global middleware


    Type parameters

    • Response
    • NextFunction

getNamespace

  • getNamespace(): string
  • get current namespace

getProcessType

  • getProcessType(): MidwayProcessTypeEnum
  • Get current running process type, app or agent, just for egg

getProjectName

  • getProjectName(): string
  • Get project name, just package.json name

setAttr

  • setAttr(key: string, value: any): any
  • Set value to app attribute map

setContextLoggerClass

  • setContextLoggerClass(BaseContextLoggerClass: any): void
  • Set a context logger class to change default context logger format

useFilter

  • useFilter<R, N>(Filter: CommonFilterUnion<Context, R, N>): void
  • add exception filter


    Type parameters

    • R
    • N

useGuard

  • useGuard(guard: CommonGuardUnion<Context>): void
  • add global guard

useMiddleware

  • useMiddleware<Response, NextFunction>(routerPath: string, ...middleware: FunctionMiddleware<Context, Response, NextFunction>[]): void
  • useMiddleware<Response, NextFunction>(middleware: CommonMiddlewareUnion<Context, Response, NextFunction>): void
  • mount router and middleware


    Type parameters

    • Response
    • NextFunction