UNPKG

2.18 kBTypeScriptView Raw
1import { INestApplication } from '@nestjs/common';
2import { FastifyInstance, FastifyPluginAsync, FastifyPluginCallback, FastifyPluginOptions, FastifyRegisterOptions } from 'fastify';
3import { Chain as LightMyRequestChain, InjectOptions, Response as LightMyRequestResponse } from 'light-my-request';
4import { FastifyStaticOptions, PointOfViewOptions } from './external';
5export interface NestFastifyApplication extends INestApplication {
6 /**
7 * A wrapper function around native `fastify.register()` method.
8 * Example `app.register(require('@fastify/formbody'))
9 * @returns {Promise<FastifyInstance>}
10 */
11 register<Options extends FastifyPluginOptions = any>(plugin: FastifyPluginCallback<Options> | FastifyPluginAsync<Options> | Promise<{
12 default: FastifyPluginCallback<Options>;
13 }> | Promise<{
14 default: FastifyPluginAsync<Options>;
15 }>, opts?: FastifyRegisterOptions<Options>): Promise<FastifyInstance>;
16 /**
17 * Sets a base directory for public assets.
18 * Example `app.useStaticAssets({ root: 'public' })`
19 * @returns {this}
20 */
21 useStaticAssets(options: FastifyStaticOptions): this;
22 /**
23 * Sets a view engine for templates (views), for example: `pug`, `handlebars`, or `ejs`.
24 *
25 * Don't pass in a string. The string type in the argument is for compatibilility reason and will cause an exception.
26 * @returns {this}
27 */
28 setViewEngine(options: PointOfViewOptions | string): this;
29 /**
30 * A wrapper function around native `fastify.inject()` method.
31 * @returns {void}
32 */
33 inject(): LightMyRequestChain;
34 inject(opts: InjectOptions | string): Promise<LightMyRequestResponse>;
35 /**
36 * Starts the application.
37 * @returns A Promise that, when resolved, is a reference to the underlying HttpServer.
38 */
39 listen(port: number | string, callback?: (err: Error, address: string) => void): Promise<any>;
40 listen(port: number | string, address: string, callback?: (err: Error, address: string) => void): Promise<any>;
41 listen(port: number | string, address: string, backlog: number, callback?: (err: Error, address: string) => void): Promise<any>;
42}