Options
All
  • Public
  • Public/Protected
  • All
Menu

daruk

Index

Type aliases

Constructor

Constructor<T>: {}

Type parameters

  • T = any

Type declaration

Next

Next: () => Promise<any>

Type declaration

    • (): Promise<any>
    • Returns Promise<any>

Variables

Const darukContainer

darukContainer: Container = new Container({skipBaseClassChecks: true})

Functions

Const DarukServer

  • DarukServer(options?: PartialOptions): Daruk

all

  • all(path: string): (Anonymous function)

cache

  • cache(callback: (cacheKey: string, shouldCacheData?: undefined | string) => Promise<string>): (Anonymous function)
  • Parameters

    • callback: (cacheKey: string, shouldCacheData?: undefined | string) => Promise<string>
        • (cacheKey: string, shouldCacheData?: undefined | string): Promise<string>
        • Parameters

          • cacheKey: string
          • Optional shouldCacheData: undefined | string

          Returns Promise<string>

    Returns (Anonymous function)

controller

  • controller(middlewares?: [{ middlewareName: string; options?: undefined | {} }]): (Anonymous function)
  • desc

    controller 装饰器,将类装饰为 controller

    Parameters

    • Optional middlewares: [{ middlewareName: string; options?: undefined | {} }]

      整个类的中间件数组

    Returns (Anonymous function)

    Decorator - 装饰器

defineMiddleware

  • defineMiddleware(middlewareName: string): (Anonymous function)

del

  • del(path: string): (Anonymous function)

disabled

  • disabled(): (Anonymous function)

get

  • get(path: string): (Anonymous function)

head

  • head(path: string): (Anonymous function)

header

  • header(key: string | {}, value?: undefined | string): (Anonymous function)

json

  • json(): (Anonymous function)
  • desc

    将函数的返回打包到 ctx.body,并返回 application/json 类型

    example

    class Class { @json() index(ctx) { return { foo: 1 } } } // the same as class Class { async index(ctx, next) { ctx.body = { foo: 1 } ctx.type = 'application/json' await next() } }

    Returns (Anonymous function)

    MethodDecorator - 装饰器

middleware

  • middleware(middlewareName: string, options?: undefined | {}): (Anonymous function)
  • desc

    middleware 中间件装饰器

    Parameters

    • middlewareName: string

      中间件的名字

    • Optional options: undefined | {}

    Returns (Anonymous function)

    Decorator - 装饰器

options

  • options(path: string): (Anonymous function)

patch

  • patch(path: string): (Anonymous function)

plugin

  • plugin(): (Anonymous function)

post

  • post(path: string): (Anonymous function)

prefix

  • prefix(path: string): (Anonymous function)
  • desc

    prefix 装饰器,对controller class的所有router进行path前缀修正

    Parameters

    • path: string

      如 /v1, /api/v1

    Returns (Anonymous function)

    ClassDecorator - 装饰器

priority

  • priority(priority: number): (Anonymous function)

put

  • put(path: string): (Anonymous function)

redirect

  • redirect(path: string): (Anonymous function)

required

  • required(config: { body?: string[]; params?: string[]; query?: string[] }): (Anonymous function)
  • Parameters

    • config: { body?: string[]; params?: string[]; query?: string[] }
      • Optional body?: string[]
      • Optional params?: string[]
      • Optional query?: string[]

    Returns (Anonymous function)

service

  • service(): (Anonymous function)

timer

  • timer(): (Anonymous function)

type

  • type(type: string): (Anonymous function)
  • 设置 response Content-Type

    example
    type('.png')
    type('png')
    type('image/png')
    type('text/plain;

    charset=utf-8')

    Parameters

    • type: string

      Content-Type 内容

    Returns (Anonymous function)

typeParse

  • typeParse(config: { body?: ParseType; params?: ParseType; query?: ParseType }): (Anonymous function)
  • Parameters

    • config: { body?: ParseType; params?: ParseType; query?: ParseType }
      • Optional body?: ParseType
      • Optional params?: ParseType
      • Optional query?: ParseType

    Returns (Anonymous function)

validate

Generated using TypeDoc