@eggjs/koa 3.1.0-beta.35 → 3.1.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application.d.ts +113 -110
- package/dist/application.js +240 -281
- package/dist/context.d.ts +163 -159
- package/dist/context.js +296 -346
- package/dist/index.d.ts +6 -7
- package/dist/index.js +9 -6
- package/dist/request.d.ts +323 -319
- package/dist/request.js +451 -514
- package/dist/response.d.ts +214 -210
- package/dist/response.js +384 -468
- package/dist/types.d.ts +12 -9
- package/package.json +31 -36
- package/dist/types.js +0 -2
package/dist/context.d.ts
CHANGED
|
@@ -1,160 +1,164 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
1
|
+
import { Response } from "./response.js";
|
|
2
|
+
import { Request, RequestSocket } from "./request.js";
|
|
3
|
+
import { AnyProto, CustomError } from "./types.js";
|
|
4
|
+
import { Application } from "./application.js";
|
|
5
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
6
|
+
import { Cookies } from "@eggjs/cookies";
|
|
7
|
+
import { ParsedUrlQuery } from "node:querystring";
|
|
8
|
+
import { Accepts } from "accepts";
|
|
9
|
+
|
|
10
|
+
//#region src/context.d.ts
|
|
11
|
+
declare class Context {
|
|
12
|
+
#private;
|
|
13
|
+
[key: symbol | string]: unknown;
|
|
14
|
+
app: Application;
|
|
15
|
+
req: IncomingMessage;
|
|
16
|
+
res: ServerResponse;
|
|
17
|
+
request: Request & AnyProto;
|
|
18
|
+
response: Response & AnyProto;
|
|
19
|
+
originalUrl: string;
|
|
20
|
+
respond?: boolean;
|
|
21
|
+
constructor(app: Application, req: IncomingMessage, res: ServerResponse);
|
|
22
|
+
/**
|
|
23
|
+
* util.inspect() implementation, which
|
|
24
|
+
* just returns the JSON output.
|
|
25
|
+
*/
|
|
26
|
+
inspect(): object;
|
|
27
|
+
/**
|
|
28
|
+
* Return JSON representation.
|
|
29
|
+
*
|
|
30
|
+
* Here we explicitly invoke .toJSON() on each
|
|
31
|
+
* object, as iteration will otherwise fail due
|
|
32
|
+
* to the getters and cause utilities such as
|
|
33
|
+
* clone() to fail.
|
|
34
|
+
*/
|
|
35
|
+
toJSON(): object;
|
|
36
|
+
/**
|
|
37
|
+
* Similar to .throw(), adds assertion.
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* this.assert(this.user, 401, 'Please login!');
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
assert(value: unknown, status?: number, errorProps?: Record<string, unknown>): void;
|
|
44
|
+
assert(value: unknown, status?: number, errorMessage?: string, errorProps?: Record<string, unknown>): void;
|
|
45
|
+
/**
|
|
46
|
+
* Throw an error with `status` (default 500) and
|
|
47
|
+
* `msg`. Note that these are user-level
|
|
48
|
+
* errors, and the message may be exposed to the client.
|
|
49
|
+
*
|
|
50
|
+
* this.throw(403)
|
|
51
|
+
* this.throw(400, 'name required')
|
|
52
|
+
* this.throw('something exploded')
|
|
53
|
+
* this.throw(new Error('invalid'))
|
|
54
|
+
* this.throw(400, new Error('invalid'))
|
|
55
|
+
* this.throw(400, new Error('invalid'), { foo: 'bar' })
|
|
56
|
+
* this.throw(new Error('invalid'), { foo: 'bar' })
|
|
57
|
+
*
|
|
58
|
+
* See: https://github.com/jshttp/http-errors
|
|
59
|
+
*
|
|
60
|
+
* Note: `status` should only be passed as the first parameter.
|
|
61
|
+
*
|
|
62
|
+
* @param {String|Number|Error} status error, msg or status
|
|
63
|
+
* @param {String|Number|Error|Object} [error] error, msg, status or errorProps
|
|
64
|
+
* @param {Object} [errorProps] error object properties
|
|
65
|
+
*/
|
|
66
|
+
throw(status: number): void;
|
|
67
|
+
throw(status: number, errorProps: object): void;
|
|
68
|
+
throw(status: number, errorMessage: string): void;
|
|
69
|
+
throw(status: number, errorMessage: string, errorProps: object): void;
|
|
70
|
+
throw(status: number, error: Error): void;
|
|
71
|
+
throw(status: number, error: Error, errorProps: object): void;
|
|
72
|
+
throw(errorMessage: string): void;
|
|
73
|
+
throw(errorMessage: string, errorProps: object): void;
|
|
74
|
+
throw(errorMessage: string, status: number): void;
|
|
75
|
+
throw(errorMessage: string, status: number, errorProps: object): void;
|
|
76
|
+
throw(error: Error): void;
|
|
77
|
+
throw(error: Error, errorProps: object): void;
|
|
78
|
+
throw(error: Error, status: number): void;
|
|
79
|
+
throw(error: Error, status: number, errorProps: object): void;
|
|
80
|
+
/**
|
|
81
|
+
* Default error handling.
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
onerror(err: CustomError): void;
|
|
85
|
+
protected _cookies: Cookies | undefined;
|
|
86
|
+
get cookies(): Cookies;
|
|
87
|
+
set cookies(cookies: Cookies);
|
|
88
|
+
get state(): Record<string, any>;
|
|
89
|
+
/**
|
|
90
|
+
* Request delegation.
|
|
91
|
+
*/
|
|
92
|
+
acceptsLanguages(): string[];
|
|
93
|
+
acceptsLanguages(languages: string[]): string | false;
|
|
94
|
+
acceptsLanguages(...languages: string[]): string | false;
|
|
95
|
+
acceptsEncodings(): string[];
|
|
96
|
+
acceptsEncodings(encodings: string[]): string | false;
|
|
97
|
+
acceptsEncodings(...encodings: string[]): string | false;
|
|
98
|
+
acceptsCharsets(): string[];
|
|
99
|
+
acceptsCharsets(charsets: string[]): string | false;
|
|
100
|
+
acceptsCharsets(...charsets: string[]): string | false;
|
|
101
|
+
accepts(args: string[]): string | string[] | false;
|
|
102
|
+
accepts(...args: string[]): string | string[] | false;
|
|
103
|
+
get<T = string | string[]>(field: string): T;
|
|
104
|
+
is(type?: string | string[], ...types: string[]): string | false | null;
|
|
105
|
+
get querystring(): string;
|
|
106
|
+
set querystring(str: string);
|
|
107
|
+
get idempotent(): boolean;
|
|
108
|
+
get socket(): RequestSocket;
|
|
109
|
+
get search(): string;
|
|
110
|
+
set search(str: string);
|
|
111
|
+
get method(): string;
|
|
112
|
+
set method(method: string);
|
|
113
|
+
get query(): ParsedUrlQuery;
|
|
114
|
+
set query(obj: ParsedUrlQuery);
|
|
115
|
+
get path(): string;
|
|
116
|
+
set path(path: string);
|
|
117
|
+
get url(): string;
|
|
118
|
+
set url(url: string);
|
|
119
|
+
get accept(): Accepts;
|
|
120
|
+
set accept(accept: Accepts);
|
|
121
|
+
get origin(): string;
|
|
122
|
+
get href(): string;
|
|
123
|
+
get subdomains(): string[];
|
|
124
|
+
get protocol(): string;
|
|
125
|
+
get host(): string;
|
|
126
|
+
get hostname(): string;
|
|
127
|
+
get URL(): URL;
|
|
128
|
+
get header(): IncomingMessage["headers"];
|
|
129
|
+
get headers(): IncomingMessage["headers"];
|
|
130
|
+
get secure(): boolean;
|
|
131
|
+
get stale(): boolean;
|
|
132
|
+
get fresh(): boolean;
|
|
133
|
+
get ips(): string[];
|
|
134
|
+
get ip(): string;
|
|
135
|
+
/**
|
|
136
|
+
* Response delegation.
|
|
137
|
+
*/
|
|
138
|
+
attachment(...args: Parameters<Response["attachment"]>): void;
|
|
139
|
+
redirect(...args: Parameters<Response["redirect"]>): void;
|
|
140
|
+
remove(...args: Parameters<Response["remove"]>): void;
|
|
141
|
+
vary(...args: Parameters<Response["vary"]>): void;
|
|
142
|
+
has(...args: Parameters<Response["has"]>): boolean;
|
|
143
|
+
set(...args: Parameters<Response["set"]>): void;
|
|
144
|
+
append(...args: Parameters<Response["append"]>): void;
|
|
145
|
+
flushHeaders(...args: Parameters<Response["flushHeaders"]>): void;
|
|
146
|
+
get status(): number;
|
|
147
|
+
set status(status: number);
|
|
148
|
+
get message(): string;
|
|
149
|
+
set message(msg: string);
|
|
150
|
+
get body(): any;
|
|
151
|
+
set body(val: any);
|
|
152
|
+
get length(): number | undefined;
|
|
153
|
+
set length(n: number | string | undefined);
|
|
154
|
+
get type(): string;
|
|
155
|
+
set type(type: string | null | undefined);
|
|
156
|
+
get lastModified(): string | Date | undefined;
|
|
157
|
+
set lastModified(val: string | Date | undefined);
|
|
158
|
+
get etag(): string;
|
|
159
|
+
set etag(val: string);
|
|
160
|
+
get headerSent(): boolean;
|
|
161
|
+
get writable(): boolean;
|
|
160
162
|
}
|
|
163
|
+
//#endregion
|
|
164
|
+
export { Context };
|