1 | /// <reference types="node" />
|
2 | import { Server } from 'http';
|
3 | import { INestApplication } from '@nestjs/common';
|
4 | import { NestExpressBodyParserOptions } from './nest-express-body-parser-options.interface';
|
5 | import { ServeStaticOptions } from './serve-static-options.interface';
|
6 | import { NestExpressBodyParserType } from './nest-express-body-parser.interface';
|
7 | /**
|
8 | * Interface describing methods on NestExpressApplication.
|
9 | *
|
10 | * @see [Platform](https://docs.nestjs.com/first-steps#platform)
|
11 | *
|
12 | * @publicApi
|
13 | */
|
14 | export interface NestExpressApplication extends INestApplication {
|
15 | /**
|
16 | * Starts the application.
|
17 | *
|
18 | * @param {number|string} port
|
19 | * @param {string} [hostname]
|
20 | * @param {Function} [callback] Optional callback
|
21 | * @returns {Promise} A Promise that, when resolved, is a reference to the underlying HttpServer.
|
22 | */
|
23 | listen(port: number | string, callback?: () => void): Promise<Server>;
|
24 | listen(port: number | string, hostname: string, callback?: () => void): Promise<Server>;
|
25 | /**
|
26 | * A wrapper function around native `express.set()` method.
|
27 | *
|
28 | * @example
|
29 | * app.set('trust proxy', 'loopback')
|
30 | *
|
31 | * @returns {this}
|
32 | */
|
33 | set(...args: any[]): this;
|
34 | /**
|
35 | * A wrapper function around native `express.engine()` method.
|
36 | * @example
|
37 | * app.engine('mustache', mustacheExpress())
|
38 | *
|
39 | * @returns {this}
|
40 | */
|
41 | engine(...args: any[]): this;
|
42 | /**
|
43 | * A wrapper function around native `express.enable()` method.
|
44 | * @example
|
45 | * app.enable('x-powered-by')
|
46 | *
|
47 | * @returns {this}
|
48 | */
|
49 | enable(...args: any[]): this;
|
50 | /**
|
51 | * A wrapper function around native `express.disable()` method.
|
52 | *
|
53 | * @example
|
54 | * app.disable('x-powered-by')
|
55 | *
|
56 | * @returns {this}
|
57 | */
|
58 | disable(...args: any[]): this;
|
59 | useStaticAssets(options: ServeStaticOptions): this;
|
60 | /**
|
61 | * Sets a base directory for public assets.
|
62 | * @example
|
63 | * app.useStaticAssets('public')
|
64 | *
|
65 | * @returns {this}
|
66 | */
|
67 | useStaticAssets(path: string, options?: ServeStaticOptions): this;
|
68 | /**
|
69 | * Register Express body parsers on the fly. Will respect
|
70 | * the application's `rawBody` option.
|
71 | *
|
72 | * @example
|
73 | * const app = await NestFactory.create<NestExpressApplication>(
|
74 | * AppModule,
|
75 | * { rawBody: true }
|
76 | * );
|
77 | * app.useBodyParser('json', { limit: '50mb' });
|
78 | *
|
79 | * @returns {this}
|
80 | */
|
81 | useBodyParser<Options = NestExpressBodyParserOptions>(parser: NestExpressBodyParserType, options?: Omit<Options, 'verify'>): this;
|
82 | /**
|
83 | * Sets one or multiple base directories for templates (views).
|
84 | *
|
85 | * @example
|
86 | * app.setBaseViewsDir('views')
|
87 | *
|
88 | * @returns {this}
|
89 | */
|
90 | setBaseViewsDir(path: string | string[]): this;
|
91 | /**
|
92 | * Sets a view engine for templates (views).
|
93 | * @example
|
94 | * app.setViewEngine('pug')
|
95 | *
|
96 | * @returns {this}
|
97 | */
|
98 | setViewEngine(engine: string): this;
|
99 | /**
|
100 | * Sets app-level globals for view templates.
|
101 | *
|
102 | * @example
|
103 | * app.setLocal('title', 'My Site')
|
104 | *
|
105 | * @see https://expressjs.com/en/4x/api.html#app.locals
|
106 | *
|
107 | * @returns {this}
|
108 | */
|
109 | setLocal(key: string, value: any): this;
|
110 | }
|