@eggjs/koa 3.1.0-beta.3 → 3.1.0-beta.31
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 +106 -123
- package/dist/application.js +281 -229
- package/dist/context.d.ts +158 -228
- package/dist/context.js +346 -304
- package/dist/index.d.ts +7 -6
- package/dist/index.js +6 -9
- package/dist/request.d.ts +319 -341
- package/dist/request.js +514 -456
- package/dist/response.d.ts +210 -230
- package/dist/response.js +468 -387
- package/dist/types.d.ts +9 -12
- package/dist/types.js +2 -0
- package/package.json +11 -10
package/dist/response.d.ts
CHANGED
|
@@ -1,231 +1,211 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
} | undefined;
|
|
212
|
-
[util.inspect.custom](): {
|
|
213
|
-
status: number;
|
|
214
|
-
message: string;
|
|
215
|
-
header: http0.OutgoingHttpHeaders;
|
|
216
|
-
} | undefined;
|
|
217
|
-
/**
|
|
218
|
-
* Return JSON representation.
|
|
219
|
-
*/
|
|
220
|
-
toJSON(): {
|
|
221
|
-
status: number;
|
|
222
|
-
message: string;
|
|
223
|
-
header: http0.OutgoingHttpHeaders;
|
|
224
|
-
};
|
|
225
|
-
/**
|
|
226
|
-
* Flush any set headers and begin the body
|
|
227
|
-
*/
|
|
228
|
-
flushHeaders(): void;
|
|
1
|
+
import Stream from 'node:stream';
|
|
2
|
+
import type { IncomingMessage, OutgoingHttpHeaders, ServerResponse } from 'node:http';
|
|
3
|
+
import { type Options as ContentDispositionOptions } from 'content-disposition';
|
|
4
|
+
import type { Application } from './application.ts';
|
|
5
|
+
import type { Context } from './context.ts';
|
|
6
|
+
import type { Request } from './request.ts';
|
|
7
|
+
export declare class Response {
|
|
8
|
+
[key: symbol]: unknown;
|
|
9
|
+
app: Application;
|
|
10
|
+
req: IncomingMessage;
|
|
11
|
+
res: ServerResponse;
|
|
12
|
+
ctx: Context;
|
|
13
|
+
request: Request;
|
|
14
|
+
constructor(app: Application, ctx: Context, req: IncomingMessage, res: ServerResponse);
|
|
15
|
+
/**
|
|
16
|
+
* Return the request socket.
|
|
17
|
+
*/
|
|
18
|
+
get socket(): ServerResponse['socket'];
|
|
19
|
+
/**
|
|
20
|
+
* Return response header.
|
|
21
|
+
*/
|
|
22
|
+
get header(): OutgoingHttpHeaders;
|
|
23
|
+
/**
|
|
24
|
+
* Return response header, alias as response.header
|
|
25
|
+
*/
|
|
26
|
+
get headers(): OutgoingHttpHeaders;
|
|
27
|
+
_explicitStatus: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Get response status code.
|
|
30
|
+
*/
|
|
31
|
+
get status(): number;
|
|
32
|
+
/**
|
|
33
|
+
* Set response status code.
|
|
34
|
+
*/
|
|
35
|
+
set status(code: number);
|
|
36
|
+
/**
|
|
37
|
+
* Get response status message
|
|
38
|
+
*/
|
|
39
|
+
get message(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Set response status message
|
|
42
|
+
*/
|
|
43
|
+
set message(msg: string);
|
|
44
|
+
_body: any;
|
|
45
|
+
_explicitNullBody: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Get response body.
|
|
48
|
+
*/
|
|
49
|
+
get body(): string | Buffer | object | Stream | null | undefined | boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Set response body.
|
|
52
|
+
*/
|
|
53
|
+
set body(val: string | Buffer | object | Stream | null | undefined | boolean);
|
|
54
|
+
/**
|
|
55
|
+
* Set Content-Length field to `n`.
|
|
56
|
+
*/
|
|
57
|
+
set length(n: number | string | undefined);
|
|
58
|
+
/**
|
|
59
|
+
* Return parsed response Content-Length when present.
|
|
60
|
+
*
|
|
61
|
+
* When Content-Length is not defined it will return `undefined`.
|
|
62
|
+
*/
|
|
63
|
+
get length(): number | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Check if a header has been written to the socket.
|
|
66
|
+
*/
|
|
67
|
+
get headerSent(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Vary on `field`.
|
|
70
|
+
*/
|
|
71
|
+
vary(field: string): void;
|
|
72
|
+
protected _getBackReferrer(): string | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Perform a 302 redirect to `url`.
|
|
75
|
+
*
|
|
76
|
+
* The string "back" is special-cased
|
|
77
|
+
* to provide Referrer support, when Referrer
|
|
78
|
+
* is not present `alt` or "/" is used.
|
|
79
|
+
*
|
|
80
|
+
* Examples:
|
|
81
|
+
*
|
|
82
|
+
* this.redirect('back');
|
|
83
|
+
* this.redirect('back', '/index.html');
|
|
84
|
+
* this.redirect('/login');
|
|
85
|
+
* this.redirect('http://google.com'); // will format to 'http://google.com/'
|
|
86
|
+
*/
|
|
87
|
+
redirect(url: string, alt?: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Set Content-Disposition header to "attachment" with optional `filename`.
|
|
90
|
+
*/
|
|
91
|
+
attachment(filename?: string, options?: ContentDispositionOptions): void;
|
|
92
|
+
/**
|
|
93
|
+
* Set Content-Type response header with `type` through `mime.lookup()`
|
|
94
|
+
* when it does not contain a charset.
|
|
95
|
+
*
|
|
96
|
+
* Examples:
|
|
97
|
+
*
|
|
98
|
+
* this.type = '.html';
|
|
99
|
+
* this.type = 'html';
|
|
100
|
+
* this.type = 'json';
|
|
101
|
+
* this.type = 'application/json';
|
|
102
|
+
* this.type = 'png';
|
|
103
|
+
*/
|
|
104
|
+
set type(type: string | null | undefined);
|
|
105
|
+
/**
|
|
106
|
+
* Return the response mime type void of
|
|
107
|
+
* parameters such as "charset".
|
|
108
|
+
*/
|
|
109
|
+
get type(): string;
|
|
110
|
+
/**
|
|
111
|
+
* Check whether the response is one of the listed types.
|
|
112
|
+
* Pretty much the same as `this.request.is()`.
|
|
113
|
+
*
|
|
114
|
+
* this.response.is('html')
|
|
115
|
+
* this.response.is('html', 'json')
|
|
116
|
+
*/
|
|
117
|
+
is(type?: string | string[], ...types: string[]): string | false;
|
|
118
|
+
/**
|
|
119
|
+
* Set the Last-Modified date using a string or a Date.
|
|
120
|
+
*
|
|
121
|
+
* this.response.lastModified = new Date();
|
|
122
|
+
* this.response.lastModified = '2013-09-13';
|
|
123
|
+
*/
|
|
124
|
+
set lastModified(val: string | Date | undefined);
|
|
125
|
+
/**
|
|
126
|
+
* Get the Last-Modified date in Date form, if it exists.
|
|
127
|
+
*/
|
|
128
|
+
get lastModified(): Date | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Set the ETag of a response.
|
|
131
|
+
* This will normalize the quotes if necessary.
|
|
132
|
+
*
|
|
133
|
+
* this.response.etag = 'md5-hash-sum';
|
|
134
|
+
* this.response.etag = '"md5-hash-sum"';
|
|
135
|
+
* this.response.etag = 'W/"123456789"';
|
|
136
|
+
*/
|
|
137
|
+
set etag(val: string);
|
|
138
|
+
/**
|
|
139
|
+
* Get the ETag of a response.
|
|
140
|
+
*/
|
|
141
|
+
get etag(): string;
|
|
142
|
+
/**
|
|
143
|
+
* Return response header.
|
|
144
|
+
*
|
|
145
|
+
* Examples:
|
|
146
|
+
*
|
|
147
|
+
* this.get('Content-Type');
|
|
148
|
+
* // => "text/plain"
|
|
149
|
+
*
|
|
150
|
+
* this.get('content-type');
|
|
151
|
+
* // => "text/plain"
|
|
152
|
+
*/
|
|
153
|
+
get<T = string | string[] | number>(field: string): T;
|
|
154
|
+
/**
|
|
155
|
+
* Returns true if the header identified by name is currently set in the outgoing headers.
|
|
156
|
+
* The header name matching is case-insensitive.
|
|
157
|
+
*
|
|
158
|
+
* Examples:
|
|
159
|
+
*
|
|
160
|
+
* this.has('Content-Type');
|
|
161
|
+
* // => true
|
|
162
|
+
*
|
|
163
|
+
* this.get('content-type');
|
|
164
|
+
* // => true
|
|
165
|
+
*/
|
|
166
|
+
has(field: string): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Set header `field` to `val` or pass
|
|
169
|
+
* an object of header fields.
|
|
170
|
+
*
|
|
171
|
+
* Examples:
|
|
172
|
+
*
|
|
173
|
+
* this.set('Foo', ['bar', 'baz']);
|
|
174
|
+
* this.set('Accept', 'application/json');
|
|
175
|
+
* this.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });
|
|
176
|
+
*/
|
|
177
|
+
set(field: string | Record<string, string>, val?: string | number | unknown[]): void;
|
|
178
|
+
/**
|
|
179
|
+
* Append additional header `field` with value `val`.
|
|
180
|
+
*
|
|
181
|
+
* Examples:
|
|
182
|
+
*
|
|
183
|
+
* ```
|
|
184
|
+
* this.append('Link', ['<http://localhost/>', '<http://localhost:3000/>']);
|
|
185
|
+
* this.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly');
|
|
186
|
+
* this.append('Warning', '199 Miscellaneous warning');
|
|
187
|
+
*/
|
|
188
|
+
append(field: string, val: string | string[]): void;
|
|
189
|
+
/**
|
|
190
|
+
* Remove header `field`.
|
|
191
|
+
*/
|
|
192
|
+
remove(field: string): void;
|
|
193
|
+
/**
|
|
194
|
+
* Checks if the request is writable.
|
|
195
|
+
* Tests for the existence of the socket
|
|
196
|
+
* as node sometimes does not set it.
|
|
197
|
+
*/
|
|
198
|
+
get writable(): boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Inspect implementation.
|
|
201
|
+
*/
|
|
202
|
+
inspect(): object | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* Return JSON representation.
|
|
205
|
+
*/
|
|
206
|
+
toJSON(): object;
|
|
207
|
+
/**
|
|
208
|
+
* Flush any set headers and begin the body
|
|
209
|
+
*/
|
|
210
|
+
flushHeaders(): void;
|
|
229
211
|
}
|
|
230
|
-
//#endregion
|
|
231
|
-
export { Response };
|