ExpressAdapter

  
class ExpressAdapter extends AbstractHttpAdapter {
  constructor(instance?: any)
  reply(response: any, body: any, statusCode?: number)
  status(response: any, statusCode: number)
  end(response: any, message?: string)
  render(response: any, view: string, options: any)
  redirect(response: any, statusCode: number, url: string)
  setErrorHandler(handler: Function, prefix?: string)
  setNotFoundHandler(handler: Function, prefix?: string)
  isHeadersSent(response: any): boolean
  getHeader(response: any, name: string)
  setHeader(response: any, name: string, value: string)
  appendHeader(response: any, name: string, value: string)
  normalizePath(path: string): string
  listen(port: any, ...args: any[]): Server
  close()
  set(...args: any[])
  enable(...args: any[])
  disable(...args: any[])
  engine(...args: any[])
  useStaticAssets(path: string, options: ServeStaticOptions)
  setBaseViewsDir(path: string | string[])
  setViewEngine(engine: string)
  getRequestHostname(request: any): string
  getRequestMethod(request: any): string
  getRequestUrl(request: any): string
  enableCors(options: any)
  createMiddlewareFactory(requestMethod: RequestMethod): (path: string, callback: Function) => any
  initHttpServer(options: NestApplicationOptions)
  registerParserMiddleware(prefix?: string, rawBody?: boolean)
  useBodyParser<Options extends NestExpressBodyParserOptions = NestExpressBodyParserOptions>(type: NestExpressBodyParserType, rawBody: boolean, options?: Omit<Options, "verify">): this
  setLocal(key: string, value: any)
  getType(): string
  applyVersionFilter(handler: Function, version: VersionValue, versioningOptions: VersioningOptions): VersionedRoute
}

Constructor


constructor(instance?: any)

Parameters

Option Type Description
instance any

Optional. Default is undefined.

Methods

reply()


reply(response: any, body: any, statusCode?: number)

Parameters

Option Type Description
response any
body any
statusCode number

Optional. Default is undefined.

status()


status(response: any, statusCode: number)

Parameters

Option Type Description
response any
statusCode number

end()


end(response: any, message?: string)

Parameters

Option Type Description
response any
message string

Optional. Default is undefined.

render()


render(response: any, view: string, options: any)

Parameters

Option Type Description
response any
view string
options any

redirect()


redirect(response: any, statusCode: number, url: string)

Parameters

Option Type Description
response any
statusCode number
url string

setErrorHandler()


setErrorHandler(handler: Function, prefix?: string)

Parameters

Option Type Description
handler Function
prefix string

Optional. Default is undefined.

setNotFoundHandler()


setNotFoundHandler(handler: Function, prefix?: string)

Parameters

Option Type Description
handler Function
prefix string

Optional. Default is undefined.

isHeadersSent()


isHeadersSent(response: any): boolean

Parameters

Option Type Description
response any

Returns

boolean

getHeader()


getHeader(response: any, name: string)

Parameters

Option Type Description
response any
name string

setHeader()


setHeader(response: any, name: string, value: string)

Parameters

Option Type Description
response any
name string
value string

appendHeader()


appendHeader(response: any, name: string, value: string)

Parameters

Option Type Description
response any
name string
value string

normalizePath()


normalizePath(path: string): string

Parameters

Option Type Description
path string

Returns

string

listen()


listen(port: string | number, callback?: () => void): Server

Parameters

Option Type Description
port string | number
callback () => void

Optional. Default is undefined.

Returns

Server


listen(port: string | number, hostname: string, callback?: () => void): Server

Parameters

Option Type Description
port string | number
hostname string
callback () => void

Optional. Default is undefined.

Returns

Server

close()


close()

Parameters

There are no parameters.

set()


set(...args: any[])

Parameters

Option Type Description
args any[]

enable()


enable(...args: any[])

Parameters

Option Type Description
args any[]

disable()


disable(...args: any[])

Parameters

Option Type Description
args any[]

engine()


engine(...args: any[])

Parameters

Option Type Description
args any[]

useStaticAssets()


useStaticAssets(path: string, options: ServeStaticOptions)

Parameters

Option Type Description
path string
options ServeStaticOptions

setBaseViewsDir()


setBaseViewsDir(path: string | string[])

Parameters

Option Type Description
path string | string[]

setViewEngine()


setViewEngine(engine: string)

Parameters

Option Type Description
engine string

getRequestHostname()


getRequestHostname(request: any): string

Parameters

Option Type Description
request any

Returns

string

getRequestMethod()


getRequestMethod(request: any): string

Parameters

Option Type Description
request any

Returns

string

getRequestUrl()


getRequestUrl(request: any): string

Parameters

Option Type Description
request any

Returns

string

enableCors()


enableCors(options: any)

Parameters

Option Type Description
options any

createMiddlewareFactory()


createMiddlewareFactory(requestMethod: RequestMethod): (path: string, callback: Function) => any

Parameters

Option Type Description
requestMethod RequestMethod

Returns

(path: string, callback: Function) => any

initHttpServer()


initHttpServer(options: NestApplicationOptions)

Parameters

Option Type Description
options NestApplicationOptions

registerParserMiddleware()


registerParserMiddleware(prefix?: string, rawBody?: boolean)

Parameters

Option Type Description
prefix string

Optional. Default is undefined.

rawBody boolean

Optional. Default is undefined.

useBodyParser()


useBodyParser<Options extends NestExpressBodyParserOptions = NestExpressBodyParserOptions>(type: NestExpressBodyParserType, rawBody: boolean, options?: Omit<Options, "verify">): this

Parameters

Option Type Description
type NestExpressBodyParserType
rawBody boolean
options Omit

Optional. Default is undefined.

Returns

this

setLocal()


setLocal(key: string, value: any)

Parameters

Option Type Description
key string
value any

getType()


getType(): string

Parameters

There are no parameters.

Returns

string

applyVersionFilter()


applyVersionFilter(handler: Function, version: VersionValue, versioningOptions: VersioningOptions): VersionedRoute

Parameters

Option Type Description
handler Function
version VersionValue
versioningOptions VersioningOptions

Returns

VersionedRoute