UNPKG

3.05 kBTypeScriptView Raw
1import { RequestMethod } from '../../enums';
2import { CorsOptions, CorsOptionsDelegate } from '../../interfaces/external/cors-options.interface';
3import { NestApplicationOptions } from '../../interfaces/nest-application-options.interface';
4export declare type ErrorHandler<TRequest = any, TResponse = any> = (error: any, req: TRequest, res: TResponse, next?: Function) => any;
5export declare type RequestHandler<TRequest = any, TResponse = any> = (req: TRequest, res: TResponse, next?: Function) => any;
6export interface HttpServer<TRequest = any, TResponse = any> {
7 use(handler: RequestHandler<TRequest, TResponse> | ErrorHandler<TRequest, TResponse>): any;
8 use(path: string, handler: RequestHandler<TRequest, TResponse> | ErrorHandler<TRequest, TResponse>): any;
9 get(handler: RequestHandler<TRequest, TResponse>): any;
10 get(path: string, handler: RequestHandler<TRequest, TResponse>): any;
11 post(handler: RequestHandler<TRequest, TResponse>): any;
12 post(path: string, handler: RequestHandler<TRequest, TResponse>): any;
13 head(handler: RequestHandler<TRequest, TResponse>): any;
14 head(path: string, handler: RequestHandler<TRequest, TResponse>): any;
15 delete(handler: RequestHandler<TRequest, TResponse>): any;
16 delete(path: string, handler: RequestHandler<TRequest, TResponse>): any;
17 put(handler: RequestHandler<TRequest, TResponse>): any;
18 put(path: string, handler: RequestHandler<TRequest, TResponse>): any;
19 patch(handler: RequestHandler<TRequest, TResponse>): any;
20 patch(path: string, handler: RequestHandler<TRequest, TResponse>): any;
21 options(handler: RequestHandler<TRequest, TResponse>): any;
22 options(path: string, handler: RequestHandler<TRequest, TResponse>): any;
23 listen(port: number | string, callback?: () => void): any;
24 listen(port: number | string, hostname: string, callback?: () => void): any;
25 reply(response: any, body: any, statusCode?: number): any;
26 status(response: any, statusCode: number): any;
27 render(response: any, view: string, options: any): any;
28 redirect(response: any, statusCode: number, url: string): any;
29 setHeader(response: any, name: string, value: string): any;
30 setErrorHandler?(handler: Function, prefix?: string): any;
31 setNotFoundHandler?(handler: Function, prefix?: string): any;
32 useStaticAssets?(...args: any[]): this;
33 setBaseViewsDir?(path: string | string[]): this;
34 setViewEngine?(engineOrOptions: any): this;
35 createMiddlewareFactory(method: RequestMethod): ((path: string, callback: Function) => any) | Promise<(path: string, callback: Function) => any>;
36 getRequestHostname?(request: TRequest): string;
37 getRequestMethod?(request: TRequest): string;
38 getRequestUrl?(request: TRequest): string;
39 getInstance(): any;
40 registerParserMiddleware(): any;
41 enableCors(options: CorsOptions | CorsOptionsDelegate<TRequest>): any;
42 getHttpServer(): any;
43 initHttpServer(options: NestApplicationOptions): void;
44 close(): any;
45 getType(): string;
46 init?(): Promise<void>;
47}