forked from nestjs/nest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnest-fastify-application.interface.ts
More file actions
72 lines (67 loc) · 2.15 KB
/
Copy pathnest-fastify-application.interface.ts
File metadata and controls
72 lines (67 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { INestApplication } from '@nestjs/common';
import {
FastifyInstance,
FastifyPluginAsync,
FastifyPluginCallback,
FastifyPluginOptions,
FastifyRegisterOptions,
} from 'fastify';
import {
Chain as LightMyRequestChain,
InjectOptions,
Response as LightMyRequestResponse,
} from 'light-my-request';
import { FastifyStaticOptions, PointOfViewOptions } from './external';
export interface NestFastifyApplication extends INestApplication {
/**
* A wrapper function around native `fastify.register()` method.
* Example `app.register(require('@fastify/formbody'))
* @returns {Promise<FastifyInstance>}
*/
register<Options extends FastifyPluginOptions = any>(
plugin:
| FastifyPluginCallback<Options>
| FastifyPluginAsync<Options>
| Promise<{ default: FastifyPluginCallback<Options> }>
| Promise<{ default: FastifyPluginAsync<Options> }>,
opts?: FastifyRegisterOptions<Options>,
): Promise<FastifyInstance>;
/**
* Sets a base directory for public assets.
* Example `app.useStaticAssets({ root: 'public' })`
* @returns {this}
*/
useStaticAssets(options: FastifyStaticOptions): this;
/**
* Sets a view engine for templates (views), for example: `pug`, `handlebars`, or `ejs`.
*
* Don't pass in a string. The string type in the argument is for compatibilility reason and will cause an exception.
* @returns {this}
*/
setViewEngine(options: PointOfViewOptions | string): this;
/**
* A wrapper function around native `fastify.inject()` method.
* @returns {void}
*/
inject(): LightMyRequestChain;
inject(opts: InjectOptions | string): Promise<LightMyRequestResponse>;
/**
* Starts the application.
* @returns A Promise that, when resolved, is a reference to the underlying HttpServer.
*/
listen(
port: number | string,
callback?: (err: Error, address: string) => void,
): Promise<any>;
listen(
port: number | string,
address: string,
callback?: (err: Error, address: string) => void,
): Promise<any>;
listen(
port: number | string,
address: string,
backlog: number,
callback?: (err: Error, address: string) => void,
): Promise<any>;
}