跳到主要内容
版本:Next

Application

Hierarchy

Index

Properties

context

context: any

keys

keys: any

maxIpsCount

maxIpsCount: number

middleware

middleware: any[]

proxy

proxy: boolean

proxyIpHeader

proxyIpHeader: string

request

request: any

response

response: any

subdomainOffset

subdomainOffset: number

Methods

addConfigObject

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

callback

  • callback(): (req: any, res: any, respond: any) => any
  • Return a request handler callback for node’s native http server.

    @api

    public

createAnonymousContext

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

createContext

  • createContext(req: any, res: any): any
  • Initialize a new context.

createLogger

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

generateMiddleware

  • @deprecated

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

getEventMiddleware

  • getEventMiddleware(): ContextMiddlewareManager<Context, NextFunction, undefined>

getFramework

  • get current related framework

getFrameworkType

  • @deprecated

    Get current framework type in MidwayFrameworkType enum

getFunctionName

  • getFunctionName(): string
  • Get function name in serverless environment

getFunctionServiceName

  • getFunctionServiceName(): string
  • Get function service name in serverless environment

getInitializeContext

  • getInitializeContext(): any

getLogger

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

getMiddleware

  • getMiddleware<R, N>(): IMiddlewareManager<Context, R, N>
  • get global middleware


    Type parameters

    • R
    • N

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

getServerlessInstance

  • getServerlessInstance<T>(serviceClass: ObjectIdentifier | new (...args: any[]) => T, customContext?: Record<string, any>): Promise<T>
  • Type parameters

    • T

inspect

  • inspect(): any
  • Inspect implementation.

    @api

    public

invokeTriggerFunction

  • invokeTriggerFunction(context: any, handler: string, options: HandlerOptions): Promise<any>

onerror

  • onerror(err: any): void
  • Default error handler.

    @api

    private

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

toJSON

  • toJSON(): any
  • Return JSON representation. We only bother showing settings.

    @api

    public

use

  • @deprecated

    use useMiddleware instead

useEventMiddleware

  • useEventMiddleware(middleware: CommonMiddlewareUnion<Context, NextFunction, undefined>): void

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<R, N>(Middleware: CommonMiddlewareUnion<Context, R, N>): void
  • add global filter to app


    Type parameters

    • R
    • N