HttpServer


interface HttpServer<TRequest = any, TResponse = any, ServerInstance = any> {
  use(handler: RequestHandler<TRequest, TResponse> | ErrorHandler<TRequest, TResponse>): any
  useBodyParser(...args: any[])?: any
  get(handler: RequestHandler<TRequest, TResponse>): any
  post(handler: RequestHandler<TRequest, TResponse>): any
  head(handler: RequestHandler<TRequest, TResponse>): any
  delete(handler: RequestHandler<TRequest, TResponse>): any
  put(handler: RequestHandler<TRequest, TResponse>): any
  patch(handler: RequestHandler<TRequest, TResponse>): any
  propfind(handler: RequestHandler<TRequest, TResponse>)?: any
  proppatch(handler: RequestHandler<TRequest, TResponse>)?: any
  mkcol(handler: RequestHandler<TRequest, TResponse>)?: any
  copy(handler: RequestHandler<TRequest, TResponse>)?: any
  move(handler: RequestHandler<TRequest, TResponse>)?: any
  lock(handler: RequestHandler<TRequest, TResponse>)?: any
  unlock(handler: RequestHandler<TRequest, TResponse>)?: any
  all(path: string, handler: RequestHandler<TRequest, TResponse>): any
  options(handler: RequestHandler<TRequest, TResponse>): any
  search(handler: RequestHandler<TRequest, TResponse>)?: any
  listen(port: string | number, callback?: () => void): any
  reply(response: any, body: any, statusCode?: number): any
  status(response: any, statusCode: number): any
  end(response: any, message?: string): any
  render(response: any, view: string, options: any): any
  redirect(response: any, statusCode: number, url: string): any
  isHeadersSent(response: any): boolean
  setHeader(response: any, name: string, value: string): any
  setErrorHandler(handler: Function, prefix?: string)?: any
  setNotFoundHandler(handler: Function, prefix?: string)?: any
  useStaticAssets(...args: any[])?: this
  setBaseViewsDir(path: string | string[])?: this
  setViewEngine(engineOrOptions: any)?: this
  createMiddlewareFactory(method: RequestMethod): ((path: string, callback: Function) => any) | Promise<(path: string, callback: Function) => any>
  getRequestHostname(request: TRequest)?: string
  getRequestMethod(request: TRequest)?: string
  getRequestUrl(request: TRequest)?: string
  getInstance(): ServerInstance
  registerParserMiddleware(...args: any[]): any
  enableCors(options: any): any
  getHttpServer(): any
  initHttpServer(options: NestApplicationOptions): void
  close(): any
  getType(): string
  init()?: Promise<void>
  applyVersionFilter(handler: Function, version: VersionValue, versioningOptions: VersioningOptions): (req: TRequest, res: TResponse, next: () => void) => Function
  normalizePath(path: string)?: string
}

Methods

use()


use(path: string, handler: RequestHandler<TRequest, TResponse> | ErrorHandler<TRequest, TResponse>): any

Parameters

Option Type Description
path string
handler RequestHandler | ErrorHandler

Returns

any

useBodyParser()


useBodyParser(...args: any[])?: any

Parameters

Option Type Description
args any[]

Returns

any

get()


get(path: string, handler: RequestHandler<TRequest, TResponse>): any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

post()


post(path: string, handler: RequestHandler<TRequest, TResponse>): any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

head()


head(path: string, handler: RequestHandler<TRequest, TResponse>): any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

delete()


delete(path: string, handler: RequestHandler<TRequest, TResponse>): any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

put()


put(path: string, handler: RequestHandler<TRequest, TResponse>): any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

patch()


patch(path: string, handler: RequestHandler<TRequest, TResponse>): any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

propfind()


propfind(path: string, handler: RequestHandler<TRequest, TResponse>)?: any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

proppatch()


proppatch(path: string, handler: RequestHandler<TRequest, TResponse>)?: any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

mkcol()


mkcol(path: string, handler: RequestHandler<TRequest, TResponse>)?: any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

copy()


copy(path: string, handler: RequestHandler<TRequest, TResponse>)?: any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

move()


move(path: string, handler: RequestHandler<TRequest, TResponse>)?: any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

lock()


lock(path: string, handler: RequestHandler<TRequest, TResponse>)?: any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

unlock()


unlock(path: string, handler: RequestHandler<TRequest, TResponse>)?: any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

all()


all(handler: RequestHandler<TRequest, TResponse>): any

Parameters

Option Type Description
handler RequestHandler

Returns

any

options()


options(path: string, handler: RequestHandler<TRequest, TResponse>): any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

search()


search(path: string, handler: RequestHandler<TRequest, TResponse>)?: any

Parameters

Option Type Description
path string
handler RequestHandler

Returns

any

listen()


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

Parameters

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

Optional. Default is undefined.

Returns

any

reply()


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

Parameters

Option Type Description
response any
body any
statusCode number

Optional. Default is undefined.

Returns

any

status()


status(response: any, statusCode: number): any

Parameters

Option Type Description
response any
statusCode number

Returns

any

end()


end(response: any, message?: string): any

Parameters

Option Type Description
response any
message string

Optional. Default is undefined.

Returns

any

render()


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

Parameters

Option Type Description
response any
view string
options any

Returns

any

redirect()


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

Parameters

Option Type Description
response any
statusCode number
url string

Returns

any

isHeadersSent()


isHeadersSent(response: any): boolean

Parameters

Option Type Description
response any

Returns

boolean

setHeader()


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

Parameters

Option Type Description
response any
name string
value string

Returns

any

setErrorHandler()


setErrorHandler(handler: Function, prefix?: string)?: any

Parameters

Option Type Description
handler Function
prefix string

Optional. Default is undefined.

Returns

any

setNotFoundHandler()


setNotFoundHandler(handler: Function, prefix?: string)?: any

Parameters

Option Type Description
handler Function
prefix string

Optional. Default is undefined.

Returns

any

useStaticAssets()


useStaticAssets(...args: any[])?: this

Parameters

Option Type Description
args any[]

Returns

this

setBaseViewsDir()


setBaseViewsDir(path: string | string[])?: this

Parameters

Option Type Description
path string | string[]

Returns

this

setViewEngine()


setViewEngine(engineOrOptions: any)?: this

Parameters

Option Type Description
engineOrOptions any

Returns

this

createMiddlewareFactory()


createMiddlewareFactory(method: RequestMethod): ((path: string, callback: Function) => any) | Promise<(path: string, callback: Function) => any>

Parameters

Option Type Description
method RequestMethod

Returns

((path: string, callback: Function) => any) | Promise<(path: string, callback: Function) => any>

getRequestHostname()


getRequestHostname(request: TRequest)?: string

Parameters

Option Type Description
request TRequest

Returns

string

getRequestMethod()


getRequestMethod(request: TRequest)?: string

Parameters

Option Type Description
request TRequest

Returns

string

getRequestUrl()


getRequestUrl(request: TRequest)?: string

Parameters

Option Type Description
request TRequest

Returns

string

getInstance()


getInstance(): ServerInstance

Parameters

There are no parameters.

Returns

ServerInstance

registerParserMiddleware()


registerParserMiddleware(...args: any[]): any

Parameters

Option Type Description
args any[]

Returns

any

enableCors()


enableCors(options: any): any

Parameters

Option Type Description
options any

Returns

any

getHttpServer()


getHttpServer(): any

Parameters

There are no parameters.

Returns

any

initHttpServer()


initHttpServer(options: NestApplicationOptions): void

Parameters

Option Type Description
options NestApplicationOptions

Returns

void

close()


close(): any

Parameters

There are no parameters.

Returns

any

getType()


getType(): string

Parameters

There are no parameters.

Returns

string

init()


init()?: Promise<void>

Parameters

There are no parameters.

Returns

Promise<void>

applyVersionFilter()


applyVersionFilter(handler: Function, version: VersionValue, versioningOptions: VersioningOptions): (req: TRequest, res: TResponse, next: () => void) => Function

Parameters

Option Type Description
handler Function
version VersionValue
versioningOptions VersioningOptions

Returns

(req: TRequest, res: TResponse, next: () => void) => Function

normalizePath()


normalizePath(path: string)?: string

Parameters

Option Type Description
path string

Returns

string