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