@opra/core 0.20.3 → 0.22.0
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/cjs/adapter/adapter.js +2 -2
- package/cjs/adapter/http/express-adapter.js +29 -7
- package/cjs/adapter/http/helpers/common.js +66 -0
- package/cjs/adapter/http/helpers/convert-to-headers.js +65 -0
- package/cjs/adapter/http/helpers/convert-to-raw-headers.js +25 -0
- package/cjs/adapter/http/helpers/match-known-fields.js +47 -0
- package/cjs/adapter/http/http-adapter.js +82 -440
- package/cjs/adapter/http/impl/http-incoming-message-host.js +127 -0
- package/cjs/adapter/http/impl/http-outgoing-message-host.js +210 -0
- package/cjs/adapter/http/impl/http-server-request.js +125 -0
- package/cjs/adapter/http/impl/http-server-response.js +226 -0
- package/cjs/adapter/http/request-parsers/batch-request-parser.js +169 -0
- package/cjs/adapter/http/request-parsers/parse-collection-request.js +165 -0
- package/cjs/adapter/http/request-parsers/parse-request.js +24 -0
- package/cjs/adapter/http/request-parsers/parse-singleton-request.js +96 -0
- package/cjs/adapter/request-context.host.js +17 -3
- package/cjs/adapter/request.host.js +6 -3
- package/cjs/adapter/response.host.js +5 -3
- package/cjs/index.js +4 -2
- package/esm/adapter/adapter.js +2 -2
- package/esm/adapter/http/express-adapter.js +6 -6
- package/esm/adapter/http/helpers/common.js +60 -0
- package/esm/adapter/http/helpers/convert-to-headers.js +60 -0
- package/esm/adapter/http/helpers/convert-to-raw-headers.js +21 -0
- package/esm/adapter/http/helpers/match-known-fields.js +43 -0
- package/esm/adapter/http/http-adapter.js +83 -441
- package/esm/adapter/http/impl/http-incoming-message-host.js +122 -0
- package/esm/adapter/http/impl/http-outgoing-message-host.js +205 -0
- package/esm/adapter/http/impl/http-server-request.js +121 -0
- package/esm/adapter/http/impl/http-server-response.js +222 -0
- package/esm/adapter/http/request-parsers/batch-request-parser.js +169 -0
- package/esm/adapter/http/request-parsers/parse-collection-request.js +161 -0
- package/esm/adapter/http/request-parsers/parse-request.js +20 -0
- package/esm/adapter/http/request-parsers/parse-singleton-request.js +92 -0
- package/esm/adapter/request-context.host.js +17 -3
- package/esm/adapter/request.host.js +6 -3
- package/esm/adapter/response.host.js +5 -3
- package/esm/index.js +4 -2
- package/package.json +19 -15
- package/types/adapter/adapter.d.ts +1 -1
- package/types/adapter/http/helpers/common.d.ts +17 -0
- package/types/adapter/http/helpers/convert-to-headers.d.ts +2 -0
- package/types/adapter/http/helpers/convert-to-raw-headers.d.ts +3 -0
- package/types/adapter/http/helpers/match-known-fields.d.ts +6 -0
- package/types/adapter/http/http-adapter.d.ts +7 -12
- package/types/adapter/http/impl/http-incoming-message-host.d.ts +58 -0
- package/types/adapter/http/impl/http-outgoing-message-host.d.ts +72 -0
- package/types/adapter/http/{http-request-message.d.ts → impl/http-server-request.d.ts} +52 -85
- package/types/adapter/http/impl/http-server-response.d.ts +137 -0
- package/types/adapter/http/request-parsers/batch-request-parser.d.ts +0 -0
- package/types/adapter/http/request-parsers/parse-collection-request.d.ts +4 -0
- package/types/adapter/http/request-parsers/parse-request.d.ts +4 -0
- package/types/adapter/http/request-parsers/parse-singleton-request.d.ts +4 -0
- package/types/adapter/interfaces/request-context.interface.d.ts +14 -10
- package/types/adapter/interfaces/request.interface.d.ts +3 -2
- package/types/adapter/interfaces/response.interface.d.ts +2 -2
- package/types/adapter/request-context.host.d.ts +9 -6
- package/types/adapter/request.host.d.ts +8 -4
- package/types/adapter/response.host.d.ts +6 -4
- package/types/index.d.ts +4 -2
- package/cjs/adapter/http/http-message.host.js +0 -251
- package/cjs/adapter/http/http-request-context.host.js +0 -28
- package/cjs/adapter/http/http-request-message.js +0 -152
- package/cjs/adapter/http/http-request.host.js +0 -14
- package/cjs/adapter/http/http-response-message.js +0 -238
- package/cjs/adapter/http/http-response.host.js +0 -14
- package/esm/adapter/http/http-message.host.js +0 -246
- package/esm/adapter/http/http-request-context.host.js +0 -24
- package/esm/adapter/http/http-request-message.js +0 -148
- package/esm/adapter/http/http-request.host.js +0 -10
- package/esm/adapter/http/http-response-message.js +0 -233
- package/esm/adapter/http/http-response.host.js +0 -10
- package/types/adapter/http/http-message.host.d.ts +0 -122
- package/types/adapter/http/http-request-context.host.d.ts +0 -16
- package/types/adapter/http/http-request.host.d.ts +0 -7
- package/types/adapter/http/http-response-message.d.ts +0 -321
- package/types/adapter/http/http-response.host.d.ts +0 -7
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import cookie from 'cookie';
|
|
4
|
-
import { Readable } from 'stream';
|
|
5
|
-
import { HttpMessage, HttpMessageHost } from './http-message.host.js';
|
|
6
|
-
import type { HttpRequestMessage } from './http-request-message.js';
|
|
7
|
-
export interface CookieOptions extends cookie.CookieSerializeOptions {
|
|
8
|
-
signed?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export interface HttpResponseMessage extends HttpMessage {
|
|
11
|
-
method?: string | undefined;
|
|
12
|
-
url?: string | undefined;
|
|
13
|
-
body?: any;
|
|
14
|
-
statusCode?: number;
|
|
15
|
-
statusMessage?: string;
|
|
16
|
-
readonly upgrade?: any;
|
|
17
|
-
/**
|
|
18
|
-
* Return request header.
|
|
19
|
-
*
|
|
20
|
-
* The `Referrer` header field is special-cased,
|
|
21
|
-
* both `Referrer` and `Referer` are interchangeable.
|
|
22
|
-
*
|
|
23
|
-
* Examples:
|
|
24
|
-
*
|
|
25
|
-
* req.get('Content-Type');
|
|
26
|
-
* // => "text/plain"
|
|
27
|
-
*
|
|
28
|
-
* req.get('content-type');
|
|
29
|
-
* // => "text/plain"
|
|
30
|
-
*
|
|
31
|
-
* req.get('Something');
|
|
32
|
-
* // => undefined
|
|
33
|
-
*
|
|
34
|
-
* Aliased as `req.header()`.
|
|
35
|
-
*/
|
|
36
|
-
get(field: string): string | undefined;
|
|
37
|
-
getHeader(name: string): number | string | string[] | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Set header `field` to `val`,
|
|
40
|
-
* or pass an object of header fields.
|
|
41
|
-
*
|
|
42
|
-
* Examples:
|
|
43
|
-
*
|
|
44
|
-
* msg.setHeader('Foo', ['bar', 'baz']);
|
|
45
|
-
* msg.setHeader('Accept', 'application/json');
|
|
46
|
-
* msg.setHeader({ Accept: 'text/plain', 'X-API-Key': 'tobi' });
|
|
47
|
-
*
|
|
48
|
-
*/
|
|
49
|
-
setHeader(name: string, value: number | string | readonly string[]): this;
|
|
50
|
-
/**
|
|
51
|
-
* Set status `code`.
|
|
52
|
-
*/
|
|
53
|
-
status(code: number): this;
|
|
54
|
-
/**
|
|
55
|
-
* Set the response HTTP status code to `statusCode` and send its string representation as the response body.
|
|
56
|
-
* @link http://expressjs.com/4x/api.html#res.sendStatus
|
|
57
|
-
*
|
|
58
|
-
* Examples:
|
|
59
|
-
*
|
|
60
|
-
* res.sendStatus(200); // equivalent to res.status(200).send('OK')
|
|
61
|
-
* res.sendStatus(403); // equivalent to res.status(403).send('Forbidden')
|
|
62
|
-
* res.sendStatus(404); // equivalent to res.status(404).send('Not Found')
|
|
63
|
-
* res.sendStatus(500); // equivalent to res.status(500).send('Internal Server Error')
|
|
64
|
-
*/
|
|
65
|
-
sendStatus(code: number): this;
|
|
66
|
-
/**
|
|
67
|
-
* Set Link header field with the given `links`.
|
|
68
|
-
*
|
|
69
|
-
* Examples:
|
|
70
|
-
*
|
|
71
|
-
* res.links({
|
|
72
|
-
* next: 'http://api.example.com/users?page=2',
|
|
73
|
-
* last: 'http://api.example.com/users?page=5'
|
|
74
|
-
* });
|
|
75
|
-
*/
|
|
76
|
-
links(links: any): this;
|
|
77
|
-
/**
|
|
78
|
-
* Send JSON response.
|
|
79
|
-
*
|
|
80
|
-
* Examples:
|
|
81
|
-
*
|
|
82
|
-
* res.json(null);
|
|
83
|
-
* res.json({ user: 'tj' });
|
|
84
|
-
* res.status(500).json('oh noes!');
|
|
85
|
-
* res.status(404).json('I dont have that');
|
|
86
|
-
*/
|
|
87
|
-
json(body: any): this;
|
|
88
|
-
/**
|
|
89
|
-
* Set _Content-Type_ response header with `type` through `mime.lookup()`
|
|
90
|
-
* when it does not contain "/", or set the Content-Type to `type` otherwise.
|
|
91
|
-
*
|
|
92
|
-
* Examples:
|
|
93
|
-
*
|
|
94
|
-
* res.type('.html');
|
|
95
|
-
* res.type('html');
|
|
96
|
-
* res.type('json');
|
|
97
|
-
* res.type('application/json');
|
|
98
|
-
* res.type('png');
|
|
99
|
-
*/
|
|
100
|
-
contentType(type: string): this;
|
|
101
|
-
/**
|
|
102
|
-
* Set _Content-Type_ response header with `type` through `mime.lookup()`
|
|
103
|
-
* when it does not contain "/", or set the Content-Type to `type` otherwise.
|
|
104
|
-
*
|
|
105
|
-
* Examples:
|
|
106
|
-
*
|
|
107
|
-
* res.type('.html');
|
|
108
|
-
* res.type('html');
|
|
109
|
-
* res.type('json');
|
|
110
|
-
* res.type('application/json');
|
|
111
|
-
* res.type('png');
|
|
112
|
-
*/
|
|
113
|
-
type(type: string): this;
|
|
114
|
-
/**
|
|
115
|
-
* Set _Content-Disposition_ header to _attachment_ with optional `filename`.
|
|
116
|
-
*/
|
|
117
|
-
attachment(filename?: string): this;
|
|
118
|
-
/**
|
|
119
|
-
* Set header `field` to `val`, or pass
|
|
120
|
-
* an object of header fields.
|
|
121
|
-
*
|
|
122
|
-
* Examples:
|
|
123
|
-
*
|
|
124
|
-
* res.set('Foo', ['bar', 'baz']);
|
|
125
|
-
* res.set('Accept', 'application/json');
|
|
126
|
-
* res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });
|
|
127
|
-
*
|
|
128
|
-
* Aliased as `res.header()`.
|
|
129
|
-
*/
|
|
130
|
-
set(field: any): this;
|
|
131
|
-
set(field: string, value?: string | string[]): this;
|
|
132
|
-
header(field: any): this;
|
|
133
|
-
header(field: string, value?: string | string[]): this;
|
|
134
|
-
append(field: string, value?: string | string[]): this;
|
|
135
|
-
/** Clear cookie `name`. */
|
|
136
|
-
clearCookie(name: string, options?: CookieOptions): this;
|
|
137
|
-
/**
|
|
138
|
-
* Set cookie `name` to `val`, with the given `options`.
|
|
139
|
-
*
|
|
140
|
-
* Options:
|
|
141
|
-
*
|
|
142
|
-
* - `maxAge` max-age in milliseconds, converted to `expires`
|
|
143
|
-
* - `signed` sign the cookie
|
|
144
|
-
* - `path` defaults to "/"
|
|
145
|
-
*
|
|
146
|
-
* Examples:
|
|
147
|
-
*
|
|
148
|
-
* // "Remember Me" for 15 minutes
|
|
149
|
-
* res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });
|
|
150
|
-
*
|
|
151
|
-
* // save as above
|
|
152
|
-
* res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })
|
|
153
|
-
*/
|
|
154
|
-
cookie(name: string, val: string, options: CookieOptions): this;
|
|
155
|
-
cookie(name: string, val: any, options: CookieOptions): this;
|
|
156
|
-
cookie(name: string, val: any): this;
|
|
157
|
-
/**
|
|
158
|
-
* Set the location header to `url`.
|
|
159
|
-
*
|
|
160
|
-
* The given `url` can also be the name of a mapped url, for
|
|
161
|
-
* example by default express supports "back" which redirects
|
|
162
|
-
* to the _Referrer_ or _Referer_ headers or "/".
|
|
163
|
-
*
|
|
164
|
-
* Examples:
|
|
165
|
-
*
|
|
166
|
-
* res.location('/foo/bar').;
|
|
167
|
-
* res.location('http://example.com');
|
|
168
|
-
* res.location('../login'); // /blog/post/1 -> /blog/login
|
|
169
|
-
*
|
|
170
|
-
* Mounting:
|
|
171
|
-
*
|
|
172
|
-
* When an application is mounted and `res.location()`
|
|
173
|
-
* is given a path that does _not_ lead with "/" it becomes
|
|
174
|
-
* relative to the mount-point. For example if the application
|
|
175
|
-
* is mounted at "/blog", the following would become "/blog/login".
|
|
176
|
-
*
|
|
177
|
-
* res.location('login');
|
|
178
|
-
*
|
|
179
|
-
* While the leading slash would result in a location of "/login":
|
|
180
|
-
*
|
|
181
|
-
* res.location('/login');
|
|
182
|
-
*/
|
|
183
|
-
location(url: string): this;
|
|
184
|
-
/**
|
|
185
|
-
* Redirect to the given `url` with optional response `status`
|
|
186
|
-
* defaulting to 302.
|
|
187
|
-
*
|
|
188
|
-
* The resulting `url` is determined by `res.location()`, so
|
|
189
|
-
* it will play nicely with mounted apps, relative paths,
|
|
190
|
-
* `"back"` etc.
|
|
191
|
-
*
|
|
192
|
-
* Examples:
|
|
193
|
-
*
|
|
194
|
-
* res.redirect('back');
|
|
195
|
-
* res.redirect('/foo/bar');
|
|
196
|
-
* res.redirect('http://example.com');
|
|
197
|
-
* res.redirect(301, 'http://example.com');
|
|
198
|
-
* res.redirect('http://example.com', 301);
|
|
199
|
-
* res.redirect('../login'); // /blog/post/1 -> /blog/login
|
|
200
|
-
*/
|
|
201
|
-
redirect(url: string): void;
|
|
202
|
-
redirect(status: number, url: string): void;
|
|
203
|
-
/** @deprecated use res.redirect(status, url) instead */
|
|
204
|
-
redirect(url: string, status: number): void;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* @namespace HttpResponseMessage
|
|
208
|
-
*/
|
|
209
|
-
export declare namespace HttpResponseMessage {
|
|
210
|
-
interface Initiator extends HttpMessage.Initiator {
|
|
211
|
-
statusCode?: number;
|
|
212
|
-
statusMessage?: string;
|
|
213
|
-
req?: HttpRequestMessage;
|
|
214
|
-
chunkedEncoding?: boolean;
|
|
215
|
-
}
|
|
216
|
-
function create(init: Initiator): HttpResponseMessage;
|
|
217
|
-
function fromBuffer(buffer: Buffer | ArrayBuffer): HttpResponseMessage;
|
|
218
|
-
function fromStream(readable: Readable): Promise<HttpResponseMessage>;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* @class HttpResponseMessageHost
|
|
222
|
-
*/
|
|
223
|
-
export declare class HttpResponseMessageHost extends HttpMessageHost implements HttpResponseMessage {
|
|
224
|
-
chunkedEncoding?: boolean;
|
|
225
|
-
req?: HttpRequestMessage;
|
|
226
|
-
statusCode?: number;
|
|
227
|
-
statusMessage?: string;
|
|
228
|
-
constructor();
|
|
229
|
-
header(name: 'set-cookie' | 'Set-Cookie', value: string | string[]): this;
|
|
230
|
-
header(name: string, value: number | string): this;
|
|
231
|
-
header(headers: Record<string, number | string | string[]>): this;
|
|
232
|
-
append(name: string, value: string | string[]): this;
|
|
233
|
-
/**
|
|
234
|
-
* Set "Content-Disposition" header to "attachment" with optional `filename`.
|
|
235
|
-
*/
|
|
236
|
-
attachment(filename?: string): this;
|
|
237
|
-
/**
|
|
238
|
-
* Alias for msg.type()
|
|
239
|
-
*/
|
|
240
|
-
contentType(type: string): this;
|
|
241
|
-
/**
|
|
242
|
-
* Set _Content-Type_ response header with `type` through `mime.lookup()`
|
|
243
|
-
* when it does not contain "/", or set the Content-Type to `type` otherwise.
|
|
244
|
-
*
|
|
245
|
-
* Examples:
|
|
246
|
-
*
|
|
247
|
-
* res.type('.html');
|
|
248
|
-
* res.type('html');
|
|
249
|
-
* res.type('json');
|
|
250
|
-
* res.type('application/json');
|
|
251
|
-
* res.type('png');
|
|
252
|
-
*/
|
|
253
|
-
type(type: string): this;
|
|
254
|
-
/**
|
|
255
|
-
* Set cookie `name` to `value`, with the given `options`.
|
|
256
|
-
*
|
|
257
|
-
* Options:
|
|
258
|
-
*
|
|
259
|
-
* - `maxAge` max-age in milliseconds, converted to `expires`
|
|
260
|
-
* - `signed` sign the cookie
|
|
261
|
-
* - `path` defaults to "/"
|
|
262
|
-
*
|
|
263
|
-
* Examples:
|
|
264
|
-
*
|
|
265
|
-
* // "Remember Me" for 15 minutes
|
|
266
|
-
* res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });
|
|
267
|
-
*
|
|
268
|
-
* // same as above
|
|
269
|
-
* res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })
|
|
270
|
-
*
|
|
271
|
-
*/
|
|
272
|
-
cookie(name: string, value: string, options?: CookieOptions): this;
|
|
273
|
-
/**
|
|
274
|
-
* Clear cookie `name`.
|
|
275
|
-
*/
|
|
276
|
-
clearCookie(name: string, options?: CookieOptions): this;
|
|
277
|
-
/**
|
|
278
|
-
* Set Link header field with the given `links`.
|
|
279
|
-
*
|
|
280
|
-
* Examples:
|
|
281
|
-
*
|
|
282
|
-
* res.links({
|
|
283
|
-
* next: 'http://api.example.com/users?page=2',
|
|
284
|
-
* last: 'http://api.example.com/users?page=5'
|
|
285
|
-
* });
|
|
286
|
-
*
|
|
287
|
-
*/
|
|
288
|
-
links(links: Record<string, string>): this;
|
|
289
|
-
redirect(url: string): any;
|
|
290
|
-
redirect(status: number, url: string): any;
|
|
291
|
-
/**
|
|
292
|
-
* Send JSON response.
|
|
293
|
-
*
|
|
294
|
-
* Examples:
|
|
295
|
-
*
|
|
296
|
-
* res.json(null);
|
|
297
|
-
* res.json({ user: 'tj' });
|
|
298
|
-
*/
|
|
299
|
-
json(obj: any): this;
|
|
300
|
-
location(url: string): this;
|
|
301
|
-
/**
|
|
302
|
-
* Set status `code`.
|
|
303
|
-
*/
|
|
304
|
-
status(code: number): this;
|
|
305
|
-
/**
|
|
306
|
-
* Set the response HTTP status code to `statusCode` and send its string representation as the response body.
|
|
307
|
-
* @link http://expressjs.com/4x/api.html#res.sendStatus
|
|
308
|
-
*
|
|
309
|
-
* Examples:
|
|
310
|
-
*
|
|
311
|
-
* res.sendStatus(200); // equivalent to res.status(200).send('OK')
|
|
312
|
-
* res.sendStatus(403); // equivalent to res.status(403).send('Forbidden')
|
|
313
|
-
* res.sendStatus(404); // equivalent to res.status(404).send('Not Found')
|
|
314
|
-
* res.sendStatus(500); // equivalent to res.status(500).send('Internal Server Error')
|
|
315
|
-
*/
|
|
316
|
-
sendStatus(statusCode: number): this;
|
|
317
|
-
protected _init(init: HttpResponseMessage.Initiator): void;
|
|
318
|
-
static create(init: HttpResponseMessage.Initiator): HttpResponseMessage;
|
|
319
|
-
static fromBuffer(buffer: Buffer | ArrayBuffer): HttpResponseMessage;
|
|
320
|
-
static fromStream(readable: Readable): Promise<HttpResponseMessage>;
|
|
321
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ResponseHost } from '../response.host.js';
|
|
2
|
-
import { HttpResponseMessage } from './http-response-message.js';
|
|
3
|
-
export declare class HttpResponseHost extends ResponseHost {
|
|
4
|
-
protected _outgoing: HttpResponseMessage;
|
|
5
|
-
constructor(init: ResponseHost.Initiator, _outgoing: HttpResponseMessage);
|
|
6
|
-
switchToHttp(): HttpResponseMessage;
|
|
7
|
-
}
|