class FastifyAdapter<TServer extends RawServerBase = RawServerDefault, TRawRequest extends FastifyRawRequest<TServer> = FastifyRawRequest<TServer>, TRawResponse extends RawReplyDefaultExpression<TServer> = RawReplyDefaultExpression<TServer>, TRequest extends FastifyRequest<RequestGenericInterface, TServer, TRawRequest> = FastifyRequest<RequestGenericInterface, TServer, TRawRequest>, TReply extends FastifyReply<RouteGenericInterface, TServer, TRawRequest, TRawResponse> = FastifyReply<RouteGenericInterface, TServer, TRawRequest, TRawResponse>, TInstance extends FastifyInstance<TServer, TRawRequest, TRawResponse> = FastifyInstance<TServer, TRawRequest, TRawResponse>> extends AbstractHttpAdapter {
constructor(instanceOrOptions?: any)
protected logger: Logger
protected instance: TInstance
protected _pathPrefix?: string
isParserRegistered: boolean
init()
listen(listenOptions: any, ...args: any[]): void
get(...args: any[])
post(...args: any[])
head(...args: any[])
delete(...args: any[])
put(...args: any[])
patch(...args: any[])
options(...args: any[])
search(...args: any[])
propfind(...args: any[])
proppatch(...args: any[])
mkcol(...args: any[])
copy(...args: any[])
move(...args: any[])
lock(...args: any[])
unlock(...args: any[])
applyVersionFilter(handler: Function, version: VersionValue, versioningOptions: VersioningOptions): VersionedRoute<TRequest, TReply>
reply(response: TRawResponse | TReply, body: any, statusCode?: number)
status(response: TRawResponse | TReply, statusCode: number)
end(response: TReply, message?: string)
render(response: TReply & { view: Function; }, view: string, options: any)
redirect(response: TReply, statusCode: number, url: string)
setErrorHandler(handler: Parameters<TInstance["setErrorHandler"]>[0])
setNotFoundHandler(handler: Function)
getHttpServer<T = TServer>(): T
getInstance<T = TInstance>(): T
register<TRegister extends Parameters<FastifyRegister<FastifyInstance<TServer, TRawRequest, TRawResponse>>>>(plugin: TRegister["0"], opts?: TRegister["1"])
inject(opts?: any): LightMyRequestChain | Promise<LightMyRequestResponse>
close()
initHttpServer()
useStaticAssets(options: FastifyStaticOptions)
setViewEngine(options: string | FastifyViewOptions)
isHeadersSent(response: TReply): boolean
getHeader(response: any, name: string)?
setHeader(response: TReply, name: string, value: string)
appendHeader(response: any, name: string, value: string)?
getRequestHostname(request: TRequest): string
getRequestMethod(request: TRequest): string
getRequestUrl(request: TRequest & TRawRequest): string
enableCors(options?: FastifyCorsOptions)
registerParserMiddleware(prefix?: string, rawBody?: boolean)
useBodyParser(type: string | RegExp | string[], rawBody: boolean, options?: NestFastifyBodyParserOptions, parser?: FastifyBodyParser<Buffer, TServer>)
createMiddlewareFactory(requestMethod: RequestMethod): Promise<(path: string, callback: Function) => any>
getType(): string
protected registerWithPrefix(factory: any, prefix: string = '/')
}
Constructor
constructor(instanceOrOptions?: any)
Parameters
Option |
Type |
Description |
instanceOrOptions
|
any |
Optional. Default is undefined .
|
|
Properties
Property |
Description |
protected logger: Logger
|
Read-only.
|
protected instance: TInstance
|
Read-only.
|
protected _pathPrefix?: string
|
|
isParserRegistered: boolean
|
Read-only.
|
Methods
init()
|
init()
Parameters
There are no parameters.
|
listen()
|
listen(port: string | number, callback?: () => void): void
Parameters
Option |
Type |
Description |
port
|
string | number |
|
callback
|
() => void |
Optional. Default is undefined .
|
Returns
void
|
listen(port: string | number, hostname: string, callback?: () => void): void
Parameters
Option |
Type |
Description |
port
|
string | number |
|
hostname
|
string |
|
callback
|
() => void |
Optional. Default is undefined .
|
Returns
void
|
get()
|
get(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
post()
|
post(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
head()
|
head(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
delete()
|
delete(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
put()
|
put(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
patch()
|
patch(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
options()
|
options(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
search()
|
search(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
propfind()
|
propfind(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
proppatch()
|
proppatch(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
mkcol()
|
mkcol(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
copy()
|
copy(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
move()
|
move(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
lock()
|
lock(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
unlock()
|
unlock(...args: any[])
Parameters
Option |
Type |
Description |
args
|
any[] |
|
|
applyVersionFilter()
|
applyVersionFilter(handler: Function, version: VersionValue, versioningOptions: VersioningOptions): VersionedRoute<TRequest, TReply>
Parameters
Option |
Type |
Description |
handler
|
Function |
|
version
|
VersionValue |
|
versioningOptions
|
VersioningOptions |
|
Returns
VersionedRoute<TRequest, TReply>
|
reply()
|
reply(response: TRawResponse | TReply, body: any, statusCode?: number)
Parameters
Option |
Type |
Description |
response
|
TRawResponse | TReply |
|
body
|
any |
|
statusCode
|
number |
Optional. Default is undefined .
|
|
status()
|
status(response: TRawResponse | TReply, statusCode: number)
Parameters
Option |
Type |
Description |
response
|
TRawResponse | TReply |
|
statusCode
|
number |
|
|
end()
|
end(response: TReply, message?: string)
Parameters
Option |
Type |
Description |
response
|
TReply |
|
message
|
string |
Optional. Default is undefined .
|
|
render()
|
render(response: TReply & { view: Function; }, view: string, options: any)
Parameters
Option |
Type |
Description |
response
|
TReply & { view: Function; } |
|
view
|
string |
|
options
|
any |
|
|
redirect()
|
redirect(response: TReply, statusCode: number, url: string)
Parameters
Option |
Type |
Description |
response
|
TReply |
|
statusCode
|
number |
|
url
|
string |
|
|
setErrorHandler()
|
setErrorHandler(handler: Parameters<TInstance["setErrorHandler"]>[0])
Parameters
Option |
Type |
Description |
handler
|
Parameters[0] |
|
|
setNotFoundHandler()
|
setNotFoundHandler(handler: Function)
Parameters
Option |
Type |
Description |
handler
|
Function |
|
|
getHttpServer()
|
getHttpServer<T = TServer>(): T
Parameters
There are no parameters.
Returns
T
|
getInstance()
|
getInstance<T = TInstance>(): T
Parameters
There are no parameters.
Returns
T
|
register()
|
register<TRegister extends Parameters<FastifyRegister<FastifyInstance<TServer, TRawRequest, TRawResponse>>>>(plugin: TRegister["0"], opts?: TRegister["1"])
Parameters
Option |
Type |
Description |
plugin
|
TRegister["0"] |
|
opts
|
TRegister["1"] |
Optional. Default is undefined .
|
|
inject()
|
inject(): LightMyRequestChain
Parameters
There are no parameters.
Returns
LightMyRequestChain
|
inject(opts: any): Promise<LightMyRequestResponse>
Parameters
Option |
Type |
Description |
opts
|
any |
|
Returns
Promise<LightMyRequestResponse>
|
close()
|
close()
Parameters
There are no parameters.
|
initHttpServer()
|
initHttpServer()
Parameters
There are no parameters.
|
useStaticAssets()
|
useStaticAssets(options: FastifyStaticOptions)
Parameters
Option |
Type |
Description |
options
|
FastifyStaticOptions |
|
|
setViewEngine()
|
setViewEngine(options: string | FastifyViewOptions)
Parameters
Option |
Type |
Description |
options
|
string | FastifyViewOptions |
|
|
|
isHeadersSent(response: TReply): boolean
Parameters
Option |
Type |
Description |
response
|
TReply |
|
Returns
boolean
|
|
getHeader(response: any, name: string)?
Parameters
Option |
Type |
Description |
response
|
any |
|
name
|
string |
|
|
|
setHeader(response: TReply, name: string, value: string)
Parameters
Option |
Type |
Description |
response
|
TReply |
|
name
|
string |
|
value
|
string |
|
|
|
appendHeader(response: any, name: string, value: string)?
Parameters
Option |
Type |
Description |
response
|
any |
|
name
|
string |
|
value
|
string |
|
|
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
|
getRequestUrl(request: TRawRequest): string
Parameters
Option |
Type |
Description |
request
|
TRawRequest |
|
Returns
string
|
enableCors()
|
enableCors(options?: FastifyCorsOptions)
Parameters
Option |
Type |
Description |
options
|
FastifyCorsOptions |
Optional. Default is undefined .
|
|
registerParserMiddleware()
|
registerParserMiddleware(prefix?: string, rawBody?: boolean)
Parameters
Option |
Type |
Description |
prefix
|
string |
Optional. Default is undefined .
|
rawBody
|
boolean |
Optional. Default is undefined .
|
|
useBodyParser()
|
useBodyParser(type: string | RegExp | string[], rawBody: boolean, options?: NestFastifyBodyParserOptions, parser?: FastifyBodyParser<Buffer, TServer>)
Parameters
Option |
Type |
Description |
type
|
string | RegExp | string[] |
|
rawBody
|
boolean |
|
options
|
NestFastifyBodyParserOptions |
Optional. Default is undefined .
|
parser
|
FastifyBodyParser |
Optional. Default is undefined .
|
|
createMiddlewareFactory()
|
createMiddlewareFactory(requestMethod: RequestMethod): Promise<(path: string, callback: Function) => any>
Parameters
Returns
Promise<(path: string, callback: Function) => any>
|
getType()
|
getType(): string
Parameters
There are no parameters.
Returns
string
|
registerWithPrefix()
|
protected registerWithPrefix(factory: any, prefix: string = '/')
Parameters
Option |
Type |
Description |
factory
|
any |
|
prefix
|
string |
Optional. Default is '/' .
|
|