UNPKG

1.51 kBTypeScriptView Raw
1import { SendOptions } from 'koa-send';
2import { HttpStatusCodes } from '../Server';
3import { ContextInterface } from '../Interface';
4export declare class Response {
5 protected ctx: ContextInterface;
6 protected headers: {
7 [header: string]: string | Array<string>;
8 };
9 protected strategy: string;
10 protected statusCode: HttpStatusCodes;
11 protected meta: any;
12 protected data: any;
13 protected message: string;
14 protected constructor({ message, data, meta, statusCode }: ResponseArgumentsInterface);
15 patchContext(ctx: ContextInterface): Promise<void>;
16 protected sendFile(): Promise<string>;
17 applyStatusCode(statusCode: HttpStatusCodes): this;
18 setStatusCode(statusCode: HttpStatusCodes): this;
19 getStatusCode(): HttpStatusCodes;
20 protected applyBody(body: any): this;
21 setHeaders(headers: {
22 [header: string]: string | Array<string>;
23 }): this;
24 addHeaders(headers: {
25 [header: string]: string | Array<string>;
26 }): this;
27 setHeader(header: string, value: string | Array<string>): this;
28 appendHeader(header: string, value: string | Array<string>): void;
29 removeHeader(header: string): this;
30 applyHeaders(): this;
31 file(location: string, options?: SendOptions): this;
32 json(data: any): this;
33 html(data: any): this;
34 protected apply(): void;
35 protected format(): any;
36}
37export interface ResponseArgumentsInterface {
38 statusCode: HttpStatusCodes;
39 message?: string;
40 data?: any;
41 meta?: any;
42}