Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Daruk

Hierarchy

  • EventEmitter
    • Daruk

Indexable

[key: string]: any

Index

Constructors

constructor

Properties

app

app: Koa

httpServer

httpServer: Server

logger

logger: KoaLogger.logger

name

name: string

options

options: Options

Static defaultMaxListeners

defaultMaxListeners: number

Methods

_initOptions

  • _initOptions(options?: PartialOptions): void
  • Parameters

    • Default value options: PartialOptions = {}

    Returns void

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

binding

  • binding(): Promise<void>

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getMaxListeners

  • getMaxListeners(): number
  • Returns number

listen

  • listen(port?: undefined | number, hostname?: undefined | string, backlog?: undefined | number, listeningListener?: undefined | (() => void)): Server
  • listen(port: number, hostname?: undefined | string, listeningListener?: undefined | (() => void)): Server
  • listen(port: number, backlog?: undefined | number, listeningListener?: undefined | (() => void)): Server
  • listen(port: number, listeningListener?: undefined | (() => void)): Server
  • listen(path: string, backlog?: undefined | number, listeningListener?: undefined | (() => void)): Server
  • listen(path: string, listeningListener?: undefined | (() => void)): Server
  • listen(handle: any, backlog?: undefined | number, listeningListener?: undefined | (() => void)): Server
  • listen(handle: any, listeningListener?: undefined | (() => void)): Server
  • listen(options: ListenOptions, listeningListener?: undefined | (() => void)): Server
  • desc

    启动服务

    Parameters

    • Optional port: undefined | number
    • Optional hostname: undefined | string
    • Optional backlog: undefined | number
    • Optional listeningListener: undefined | (() => void)

    Returns Server

  • Parameters

    • port: number
    • Optional hostname: undefined | string
    • Optional listeningListener: undefined | (() => void)

    Returns Server

  • Parameters

    • port: number
    • Optional backlog: undefined | number
    • Optional listeningListener: undefined | (() => void)

    Returns Server

  • Parameters

    • port: number
    • Optional listeningListener: undefined | (() => void)

    Returns Server

  • Parameters

    • path: string
    • Optional backlog: undefined | number
    • Optional listeningListener: undefined | (() => void)

    Returns Server

  • Parameters

    • path: string
    • Optional listeningListener: undefined | (() => void)

    Returns Server

  • Parameters

    • handle: any
    • Optional backlog: undefined | number
    • Optional listeningListener: undefined | (() => void)

    Returns Server

  • Parameters

    • handle: any
    • Optional listeningListener: undefined | (() => void)

    Returns Server

  • Parameters

    • options: ListenOptions
    • Optional listeningListener: undefined | (() => void)

    Returns Server

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

loadFile

  • loadFile(path: string): Promise<void>

mockContext

  • mockContext(req?: undefined | {}): ParameterizedContext<DefaultState, DefaultContext>
  • desc

    模拟 ctx,从而可以从非请求链路中得到 ctx

    Parameters

    • Optional req: undefined | {}

      配置模拟请求的 headers、query、url 等

    Returns ParameterizedContext<DefaultState, DefaultContext>

    Daruk.Context

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prettyLog

  • prettyLog(msg: string, ext?: undefined | { init?: undefined | false | true; level?: undefined | string; type?: undefined | string }): void
  • desc

    在开发环境下输出 format 日志 正式环境下仍旧保持纯文本输出

    Parameters

    • msg: string
    • Optional ext: undefined | { init?: undefined | false | true; level?: undefined | string; type?: undefined | string }

    Returns void

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc