@h3ravel/http 11.6.0 → 11.6.1
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/app.globals.d.ts +5 -1
- package/dist/{find-up-simple-CPevfdC2.cjs → find-up-simple-C7LasaJE.cjs} +0 -1
- package/dist/index.cjs +4109 -2367
- package/dist/index.d.ts +1240 -427
- package/dist/index.js +4962 -3214
- package/package.json +8 -8
- package/dist/index.d.cts +0 -1084
package/dist/index.d.cts
DELETED
|
@@ -1,1084 +0,0 @@
|
|
|
1
|
-
/// <reference path="./app.globals.d.ts" />
|
|
2
|
-
import { EventHandlerRequest, H3Event, HTTPResponse } from "h3";
|
|
3
|
-
import { DotNestedKeys, DotNestedValue, HttpContext as HttpContext$1, IApplication, IMiddleware, IParamBag, IRequest, IResponse, RequestMethod, RequestObject } from "@h3ravel/shared";
|
|
4
|
-
import { Command } from "@h3ravel/musket";
|
|
5
|
-
import { Application } from "@h3ravel/core";
|
|
6
|
-
import { Url } from "@h3ravel/url";
|
|
7
|
-
|
|
8
|
-
//#region src/Bags/ParamBag.d.ts
|
|
9
|
-
/**
|
|
10
|
-
* ParamBag is a container for key/value pairs
|
|
11
|
-
* for Node/H3 environments.
|
|
12
|
-
*/
|
|
13
|
-
declare class ParamBag implements IParamBag {
|
|
14
|
-
protected parameters: RequestObject;
|
|
15
|
-
/**
|
|
16
|
-
* The current H3 H3Event instance
|
|
17
|
-
*/
|
|
18
|
-
readonly event: H3Event;
|
|
19
|
-
constructor(parameters: RequestObject | undefined,
|
|
20
|
-
/**
|
|
21
|
-
* The current H3 H3Event instance
|
|
22
|
-
*/
|
|
23
|
-
event: H3Event);
|
|
24
|
-
/**
|
|
25
|
-
* Returns the parameters.
|
|
26
|
-
* @
|
|
27
|
-
* @param key The name of the parameter to return or null to get them all
|
|
28
|
-
*
|
|
29
|
-
* @throws BadRequestException if the value is not an array
|
|
30
|
-
*/
|
|
31
|
-
all(key?: string): any;
|
|
32
|
-
get(key: string, defaultValue?: any): any;
|
|
33
|
-
set(key: string, value: any): void;
|
|
34
|
-
/**
|
|
35
|
-
* Returns true if the parameter is defined.
|
|
36
|
-
*
|
|
37
|
-
* @param key
|
|
38
|
-
*/
|
|
39
|
-
has(key: string): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Removes a parameter.
|
|
42
|
-
*
|
|
43
|
-
* @param key
|
|
44
|
-
*/
|
|
45
|
-
remove(key: string): void;
|
|
46
|
-
/**
|
|
47
|
-
*
|
|
48
|
-
* Returns the parameter as string.
|
|
49
|
-
*
|
|
50
|
-
* @param key
|
|
51
|
-
* @param defaultValue
|
|
52
|
-
* @throws UnexpectedValueException if the value cannot be converted to string
|
|
53
|
-
* @returns
|
|
54
|
-
*/
|
|
55
|
-
getString(key: string, defaultValue?: string): string;
|
|
56
|
-
/**
|
|
57
|
-
* Returns the parameter value converted to integer.
|
|
58
|
-
*
|
|
59
|
-
* @param key
|
|
60
|
-
* @param defaultValue
|
|
61
|
-
* @throws UnexpectedValueException if the value cannot be converted to integer
|
|
62
|
-
*/
|
|
63
|
-
getInt(key: string, defaultValue?: number): number;
|
|
64
|
-
/**
|
|
65
|
-
* Returns the parameter value converted to boolean.
|
|
66
|
-
*
|
|
67
|
-
* @param key
|
|
68
|
-
* @param defaultValue
|
|
69
|
-
* @throws UnexpectedValueException if the value cannot be converted to a boolean
|
|
70
|
-
*/
|
|
71
|
-
getBoolean(key: string, defaultValue?: boolean): boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Returns the alphabetic characters of the parameter value.
|
|
74
|
-
*
|
|
75
|
-
* @param key
|
|
76
|
-
* @param defaultValue
|
|
77
|
-
* @throws UnexpectedValueException if the value cannot be converted to string
|
|
78
|
-
*/
|
|
79
|
-
getAlpha(key: string, defaultValue?: string): string;
|
|
80
|
-
/**
|
|
81
|
-
* Returns the alphabetic characters and digits of the parameter value.
|
|
82
|
-
*
|
|
83
|
-
* @param key
|
|
84
|
-
* @param defaultValue
|
|
85
|
-
* @throws UnexpectedValueException if the value cannot be converted to string
|
|
86
|
-
*/
|
|
87
|
-
getAlnum(key: string, defaultValue?: string): string;
|
|
88
|
-
/**
|
|
89
|
-
* Returns the digits of the parameter value.
|
|
90
|
-
*
|
|
91
|
-
* @param key
|
|
92
|
-
* @param defaultValue
|
|
93
|
-
* @throws UnexpectedValueException if the value cannot be converted to string
|
|
94
|
-
* @returns
|
|
95
|
-
**/
|
|
96
|
-
getDigits(key: string, defaultValue?: string): string;
|
|
97
|
-
/**
|
|
98
|
-
* Returns the parameter keys.
|
|
99
|
-
*/
|
|
100
|
-
keys(): string[];
|
|
101
|
-
/**
|
|
102
|
-
* Replaces the current parameters by a new set.
|
|
103
|
-
*/
|
|
104
|
-
replace(parameters?: RequestObject): void;
|
|
105
|
-
/**
|
|
106
|
-
* Adds parameters.
|
|
107
|
-
*/
|
|
108
|
-
add(parameters?: RequestObject): void;
|
|
109
|
-
/**
|
|
110
|
-
* Returns the number of parameters.
|
|
111
|
-
*/
|
|
112
|
-
count(): number;
|
|
113
|
-
/**
|
|
114
|
-
* Returns an iterator for parameters.
|
|
115
|
-
*
|
|
116
|
-
* @returns
|
|
117
|
-
*/
|
|
118
|
-
[Symbol.iterator](): ArrayIterator<[string, any]>;
|
|
119
|
-
}
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/UploadedFile.d.ts
|
|
122
|
-
declare class UploadedFile {
|
|
123
|
-
originalName: string;
|
|
124
|
-
mimeType: string;
|
|
125
|
-
size: number;
|
|
126
|
-
content: File;
|
|
127
|
-
constructor(originalName: string, mimeType: string, size: number, content: File);
|
|
128
|
-
static createFromBase(file: File): UploadedFile;
|
|
129
|
-
/**
|
|
130
|
-
* Save to disk (Node environment only)
|
|
131
|
-
*/
|
|
132
|
-
moveTo(destination: string): Promise<void>;
|
|
133
|
-
}
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region src/Bags/FileBag.d.ts
|
|
136
|
-
type FileInput = UploadedFile | File | null | undefined;
|
|
137
|
-
/**
|
|
138
|
-
* FileBag is a container for uploaded files
|
|
139
|
-
* for Node/H3 environments.
|
|
140
|
-
*/
|
|
141
|
-
declare class FileBag extends ParamBag {
|
|
142
|
-
protected parameters: Record<string, UploadedFile | UploadedFile[] | null>;
|
|
143
|
-
constructor(parameters: Record<string, FileInput | FileInput[]> | undefined,
|
|
144
|
-
/**
|
|
145
|
-
* The current H3 H3Event instance
|
|
146
|
-
*/
|
|
147
|
-
event: H3Event);
|
|
148
|
-
/**
|
|
149
|
-
* Replace all stored files.
|
|
150
|
-
*/
|
|
151
|
-
replace(files?: Record<string, FileInput | FileInput[]>): void;
|
|
152
|
-
/**
|
|
153
|
-
* Set a file or array of files.
|
|
154
|
-
*/
|
|
155
|
-
set(key: string, value: FileInput | FileInput[]): void;
|
|
156
|
-
/**
|
|
157
|
-
* Add multiple files.
|
|
158
|
-
*/
|
|
159
|
-
add(files?: Record<string, FileInput | FileInput[]>): void;
|
|
160
|
-
/**
|
|
161
|
-
* Get all stored files.
|
|
162
|
-
*/
|
|
163
|
-
all(): Record<string, UploadedFile | UploadedFile[] | null>;
|
|
164
|
-
/**
|
|
165
|
-
* Normalize file input into UploadedFile instances.
|
|
166
|
-
*/
|
|
167
|
-
protected convertFileInformation(file: FileInput): UploadedFile | null;
|
|
168
|
-
}
|
|
169
|
-
//#endregion
|
|
170
|
-
//#region src/Bags/HeaderBag.d.ts
|
|
171
|
-
/**
|
|
172
|
-
* HeaderBag — A container for HTTP headers
|
|
173
|
-
* for Node/H3 environments.
|
|
174
|
-
*/
|
|
175
|
-
declare class HeaderBag implements Iterable<[string, (string | null)[]]> {
|
|
176
|
-
protected static readonly UPPER = "_ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
177
|
-
protected static readonly LOWER = "-abcdefghijklmnopqrstuvwxyz";
|
|
178
|
-
protected headers: Record<string, (string | null)[]>;
|
|
179
|
-
protected cacheControl: Record<string, string | boolean>;
|
|
180
|
-
constructor(headers?: Record<string, string | string[] | null>);
|
|
181
|
-
/**
|
|
182
|
-
* Returns all headers as string (for debugging / toString)
|
|
183
|
-
*
|
|
184
|
-
* @returns
|
|
185
|
-
*/
|
|
186
|
-
toString(): string;
|
|
187
|
-
/**
|
|
188
|
-
* Returns all headers or specific header list
|
|
189
|
-
*
|
|
190
|
-
* @param key
|
|
191
|
-
* @returns
|
|
192
|
-
*/
|
|
193
|
-
all(key?: string): Record<string, (string | null)[]> | (string | null)[];
|
|
194
|
-
/**
|
|
195
|
-
* Returns header keys
|
|
196
|
-
*
|
|
197
|
-
* @returns
|
|
198
|
-
*/
|
|
199
|
-
keys(): string[];
|
|
200
|
-
/**
|
|
201
|
-
* Replace all headers with new set
|
|
202
|
-
*
|
|
203
|
-
* @param headers
|
|
204
|
-
*/
|
|
205
|
-
replace(headers?: Record<string, string | string[] | null>): void;
|
|
206
|
-
/**
|
|
207
|
-
* Add multiple headers
|
|
208
|
-
*
|
|
209
|
-
* @param headers
|
|
210
|
-
*/
|
|
211
|
-
add(headers: Record<string, string | string[] | null>): void;
|
|
212
|
-
/**
|
|
213
|
-
* Returns first header value by name or default
|
|
214
|
-
*
|
|
215
|
-
* @param key
|
|
216
|
-
* @param defaultValue
|
|
217
|
-
* @returns
|
|
218
|
-
*/
|
|
219
|
-
get<R = undefined>(key: string, defaultValue?: string | null): R extends undefined ? string | null : R;
|
|
220
|
-
/**
|
|
221
|
-
* Sets a header by name.
|
|
222
|
-
*
|
|
223
|
-
* @param replace Whether to replace existing values (default true)
|
|
224
|
-
*/
|
|
225
|
-
set(key: string, values: string | string[] | null, replace?: boolean): void;
|
|
226
|
-
/**
|
|
227
|
-
* Returns true if header exists
|
|
228
|
-
*
|
|
229
|
-
* @param key
|
|
230
|
-
* @returns
|
|
231
|
-
*/
|
|
232
|
-
has(key: string): boolean;
|
|
233
|
-
/**
|
|
234
|
-
* Returns true if header contains value
|
|
235
|
-
*
|
|
236
|
-
* @param key
|
|
237
|
-
* @param value
|
|
238
|
-
* @returns
|
|
239
|
-
*/
|
|
240
|
-
contains(key: string, value: string): boolean;
|
|
241
|
-
/**
|
|
242
|
-
* Removes a header
|
|
243
|
-
*
|
|
244
|
-
* @param key
|
|
245
|
-
*/
|
|
246
|
-
remove(key: string): void;
|
|
247
|
-
/**
|
|
248
|
-
* Returns parsed date from header
|
|
249
|
-
*
|
|
250
|
-
* @param key
|
|
251
|
-
* @param defaultValue
|
|
252
|
-
* @returns
|
|
253
|
-
*/
|
|
254
|
-
getDate(key: string, defaultValue?: Date | null): Date | null;
|
|
255
|
-
/**
|
|
256
|
-
* Adds a Cache-Control directive
|
|
257
|
-
*
|
|
258
|
-
* @param key
|
|
259
|
-
* @param value
|
|
260
|
-
*/
|
|
261
|
-
addCacheControlDirective(key: string, value?: string | boolean): void;
|
|
262
|
-
/**
|
|
263
|
-
* Returns true if Cache-Control directive is defined
|
|
264
|
-
*
|
|
265
|
-
* @param key
|
|
266
|
-
* @returns
|
|
267
|
-
*/
|
|
268
|
-
hasCacheControlDirective(key: string): boolean;
|
|
269
|
-
/**
|
|
270
|
-
* Returns a Cache-Control directive value by name
|
|
271
|
-
*
|
|
272
|
-
* @param key
|
|
273
|
-
* @returns
|
|
274
|
-
*/
|
|
275
|
-
getCacheControlDirective(key: string): string | boolean | null;
|
|
276
|
-
/**
|
|
277
|
-
* Removes a Cache-Control directive
|
|
278
|
-
*
|
|
279
|
-
* @param key
|
|
280
|
-
* @returns
|
|
281
|
-
*/
|
|
282
|
-
removeCacheControlDirective(key: string): void;
|
|
283
|
-
/**
|
|
284
|
-
* Number of headers
|
|
285
|
-
*
|
|
286
|
-
* @param key
|
|
287
|
-
* @returns
|
|
288
|
-
*/
|
|
289
|
-
count(): number;
|
|
290
|
-
/**
|
|
291
|
-
* Normalize header name to lowercase with hyphens
|
|
292
|
-
*
|
|
293
|
-
* @param key
|
|
294
|
-
* @returns
|
|
295
|
-
*/
|
|
296
|
-
protected normalizeKey(key: string): string;
|
|
297
|
-
/**
|
|
298
|
-
* Generates Cache-Control header string
|
|
299
|
-
*
|
|
300
|
-
* @param header
|
|
301
|
-
* @returns
|
|
302
|
-
*/
|
|
303
|
-
protected getCacheControlHeader(): string;
|
|
304
|
-
/**
|
|
305
|
-
* Parses Cache-Control header
|
|
306
|
-
*
|
|
307
|
-
* @param header
|
|
308
|
-
* @returns
|
|
309
|
-
*/
|
|
310
|
-
protected parseCacheControl(header: string): Record<string, string | boolean>;
|
|
311
|
-
/**
|
|
312
|
-
* Iterator support
|
|
313
|
-
* @returns
|
|
314
|
-
*/
|
|
315
|
-
[Symbol.iterator](): Iterator<[string, (string | null)[]]>;
|
|
316
|
-
}
|
|
317
|
-
//#endregion
|
|
318
|
-
//#region src/Bags/InputBag.d.ts
|
|
319
|
-
/**
|
|
320
|
-
* InputBag is a container for user input values
|
|
321
|
-
* (e.g., query params, body, cookies)
|
|
322
|
-
* for Node/H3 environments.
|
|
323
|
-
*/
|
|
324
|
-
declare class InputBag extends ParamBag {
|
|
325
|
-
constructor(inputs: RequestObject | undefined,
|
|
326
|
-
/**
|
|
327
|
-
* The current H3 H3Event instance
|
|
328
|
-
*/
|
|
329
|
-
event: H3Event);
|
|
330
|
-
/**
|
|
331
|
-
* Returns a scalar input value by name.
|
|
332
|
-
*
|
|
333
|
-
* @param key
|
|
334
|
-
* @param defaultValue
|
|
335
|
-
* @throws BadRequestException if the input contains a non-scalar value
|
|
336
|
-
* @returns
|
|
337
|
-
*/
|
|
338
|
-
get<T extends string | number | boolean | null>(key: string, defaultValue?: T | null): T | string | number | boolean | null;
|
|
339
|
-
/**
|
|
340
|
-
* Replaces all current input values.
|
|
341
|
-
*
|
|
342
|
-
* @param inputs
|
|
343
|
-
* @returns
|
|
344
|
-
*/
|
|
345
|
-
replace(inputs?: RequestObject): void;
|
|
346
|
-
/**
|
|
347
|
-
* Adds multiple input values.
|
|
348
|
-
*
|
|
349
|
-
* @param inputs
|
|
350
|
-
* @returns
|
|
351
|
-
*/
|
|
352
|
-
add(inputs?: RequestObject): void;
|
|
353
|
-
/**
|
|
354
|
-
* Sets an input by name.
|
|
355
|
-
*
|
|
356
|
-
* @param key
|
|
357
|
-
* @param value
|
|
358
|
-
* @throws TypeError if value is not scalar or array
|
|
359
|
-
* @returns
|
|
360
|
-
*/
|
|
361
|
-
set(key: string, value: any): void;
|
|
362
|
-
/**
|
|
363
|
-
* Returns true if a key exists.
|
|
364
|
-
*
|
|
365
|
-
* @param key
|
|
366
|
-
* @returns
|
|
367
|
-
*/
|
|
368
|
-
has(key: string): boolean;
|
|
369
|
-
/**
|
|
370
|
-
* Returns all parameters.
|
|
371
|
-
*
|
|
372
|
-
* @returns
|
|
373
|
-
*/
|
|
374
|
-
all(): RequestObject;
|
|
375
|
-
/**
|
|
376
|
-
* Converts a parameter value to string.
|
|
377
|
-
*
|
|
378
|
-
* @param key
|
|
379
|
-
* @param defaultValue
|
|
380
|
-
* @throws BadRequestException if input contains a non-scalar value
|
|
381
|
-
* @returns
|
|
382
|
-
*/
|
|
383
|
-
getString(key: string, defaultValue?: string): string;
|
|
384
|
-
/**
|
|
385
|
-
* Filters input value with a predicate.
|
|
386
|
-
* Mimics PHP’s filter_var() in spirit, but simpler.
|
|
387
|
-
*
|
|
388
|
-
* @param key
|
|
389
|
-
* @param defaultValue
|
|
390
|
-
* @param filterFn
|
|
391
|
-
* @throws BadRequestException if validation fails
|
|
392
|
-
* @returns
|
|
393
|
-
*/
|
|
394
|
-
filter<T = any>(key: string, defaultValue?: T | null, filterFn?: (value: any) => boolean): T | null;
|
|
395
|
-
/**
|
|
396
|
-
* Returns an enum value by key.
|
|
397
|
-
*
|
|
398
|
-
* @param key
|
|
399
|
-
* @param EnumClass
|
|
400
|
-
* @param defaultValue
|
|
401
|
-
* @throws BadRequestException if conversion fails
|
|
402
|
-
* @returns
|
|
403
|
-
*/
|
|
404
|
-
getEnum<T extends Record<string, string | number>>(key: string, EnumClass: T, defaultValue?: T[keyof T] | null): T[keyof T] | null;
|
|
405
|
-
/**
|
|
406
|
-
* Removes a key.
|
|
407
|
-
*
|
|
408
|
-
* @param key
|
|
409
|
-
*/
|
|
410
|
-
remove(key: string): void;
|
|
411
|
-
/**
|
|
412
|
-
* Returns all keys.
|
|
413
|
-
*
|
|
414
|
-
* @returns
|
|
415
|
-
*/
|
|
416
|
-
keys(): string[];
|
|
417
|
-
/**
|
|
418
|
-
* Returns number of parameters.
|
|
419
|
-
*
|
|
420
|
-
* @returns
|
|
421
|
-
*/
|
|
422
|
-
count(): number;
|
|
423
|
-
}
|
|
424
|
-
//#endregion
|
|
425
|
-
//#region src/Bags/ServerBag.d.ts
|
|
426
|
-
/**
|
|
427
|
-
* ServerBag — a simplified version of Symfony's ServerBag
|
|
428
|
-
* for Node/H3 environments.
|
|
429
|
-
*
|
|
430
|
-
* Responsible for extracting and normalizing HTTP headers
|
|
431
|
-
* from the incoming request.
|
|
432
|
-
*/
|
|
433
|
-
declare class ServerBag extends ParamBag {
|
|
434
|
-
constructor(parameters: Record<string, string | undefined> | undefined,
|
|
435
|
-
/**
|
|
436
|
-
* The current H3 H3Event instance
|
|
437
|
-
*/
|
|
438
|
-
event: H3Event);
|
|
439
|
-
/**
|
|
440
|
-
* Returns all request headers, normalized to uppercase with underscores.
|
|
441
|
-
* Example: content-type → CONTENT_TYPE
|
|
442
|
-
*/
|
|
443
|
-
getHeaders(): Record<string, string>;
|
|
444
|
-
/**
|
|
445
|
-
* Returns a specific header by name, case-insensitive.
|
|
446
|
-
*/
|
|
447
|
-
get(name: string): string | undefined;
|
|
448
|
-
/**
|
|
449
|
-
* Returns true if a header exists.
|
|
450
|
-
*/
|
|
451
|
-
has(name: string): boolean;
|
|
452
|
-
}
|
|
453
|
-
//#endregion
|
|
454
|
-
//#region src/Commands/FireCommand.d.ts
|
|
455
|
-
declare class FireCommand extends Command {
|
|
456
|
-
/**
|
|
457
|
-
* The name and signature of the console command.
|
|
458
|
-
*
|
|
459
|
-
* @var string
|
|
460
|
-
*/
|
|
461
|
-
protected signature: string;
|
|
462
|
-
/**
|
|
463
|
-
* The console command description.
|
|
464
|
-
*
|
|
465
|
-
* @var string
|
|
466
|
-
*/
|
|
467
|
-
protected description: string;
|
|
468
|
-
handle(): Promise<void>;
|
|
469
|
-
protected fire(): Promise<void>;
|
|
470
|
-
}
|
|
471
|
-
//#endregion
|
|
472
|
-
//#region src/Exceptions/BadRequestException.d.ts
|
|
473
|
-
declare class BadRequestException extends Error {
|
|
474
|
-
constructor(message: string);
|
|
475
|
-
}
|
|
476
|
-
//#endregion
|
|
477
|
-
//#region src/Exceptions/SuspiciousOperationException.d.ts
|
|
478
|
-
declare class SuspiciousOperationException extends Error {
|
|
479
|
-
constructor(message: string);
|
|
480
|
-
}
|
|
481
|
-
//#endregion
|
|
482
|
-
//#region src/Exceptions/UnexpectedValueException.d.ts
|
|
483
|
-
declare class UnexpectedValueException extends Error {
|
|
484
|
-
constructor(message: string);
|
|
485
|
-
}
|
|
486
|
-
//#endregion
|
|
487
|
-
//#region src/FormRequest.d.ts
|
|
488
|
-
declare class FormRequest {
|
|
489
|
-
protected dataset: {
|
|
490
|
-
files: Record<string, File | UploadedFile | (File | UploadedFile)[]>;
|
|
491
|
-
input: Record<string, any>;
|
|
492
|
-
};
|
|
493
|
-
constructor(data: FormData);
|
|
494
|
-
/**
|
|
495
|
-
* Initialize the data
|
|
496
|
-
* @param data
|
|
497
|
-
*/
|
|
498
|
-
initialize(data: FormData): void;
|
|
499
|
-
/**
|
|
500
|
-
* Get all uploaded files
|
|
501
|
-
*/
|
|
502
|
-
files(): Record<string, File | UploadedFile | (File | UploadedFile)[]>;
|
|
503
|
-
/**
|
|
504
|
-
* Get all input fields
|
|
505
|
-
*/
|
|
506
|
-
input(): Record<string, any>;
|
|
507
|
-
/**
|
|
508
|
-
* Get combined input and files
|
|
509
|
-
* File entries take precedence if names overlap.
|
|
510
|
-
*/
|
|
511
|
-
all(): Record<string, any>;
|
|
512
|
-
}
|
|
513
|
-
//#endregion
|
|
514
|
-
//#region src/HttpContext.d.ts
|
|
515
|
-
/**
|
|
516
|
-
* Represents the HTTP context for a single request lifecycle.
|
|
517
|
-
* Encapsulates the application instance, request, and response objects.
|
|
518
|
-
*/
|
|
519
|
-
declare class HttpContext implements HttpContext$1 {
|
|
520
|
-
app: IApplication;
|
|
521
|
-
request: IRequest;
|
|
522
|
-
response: IResponse;
|
|
523
|
-
private static contexts;
|
|
524
|
-
constructor(app: IApplication, request: IRequest, response: IResponse);
|
|
525
|
-
/**
|
|
526
|
-
* Factory method to create a new HttpContext instance from a context object.
|
|
527
|
-
* @param ctx - Object containing app, request, and response
|
|
528
|
-
* @returns A new HttpContext instance
|
|
529
|
-
*/
|
|
530
|
-
static init(ctx: {
|
|
531
|
-
app: IApplication;
|
|
532
|
-
request: IRequest;
|
|
533
|
-
response: IResponse;
|
|
534
|
-
}, event?: unknown): HttpContext;
|
|
535
|
-
/**
|
|
536
|
-
* Retrieve an existing HttpContext instance for an event, if any.
|
|
537
|
-
*/
|
|
538
|
-
static get(event: unknown): HttpContext | undefined;
|
|
539
|
-
/**
|
|
540
|
-
* Delete the cached context for a given event (optional cleanup).
|
|
541
|
-
*/
|
|
542
|
-
static forget(event: unknown): void;
|
|
543
|
-
}
|
|
544
|
-
//#endregion
|
|
545
|
-
//#region src/Middleware.d.ts
|
|
546
|
-
declare abstract class Middleware implements IMiddleware {
|
|
547
|
-
abstract handle(context: HttpContext, next: () => Promise<unknown>): Promise<unknown>;
|
|
548
|
-
}
|
|
549
|
-
//#endregion
|
|
550
|
-
//#region src/Middleware/LogRequests.d.ts
|
|
551
|
-
declare class LogRequests extends Middleware {
|
|
552
|
-
handle({
|
|
553
|
-
request
|
|
554
|
-
}: HttpContext, next: () => Promise<unknown>): Promise<unknown>;
|
|
555
|
-
}
|
|
556
|
-
//#endregion
|
|
557
|
-
//#region src/Providers/HttpServiceProvider.d.ts
|
|
558
|
-
/**
|
|
559
|
-
* Sets up HTTP kernel and request lifecycle.
|
|
560
|
-
*
|
|
561
|
-
* Register Request, Response, and Middleware classes.
|
|
562
|
-
* Configure global middleware stack.
|
|
563
|
-
* Boot HTTP kernel.
|
|
564
|
-
*
|
|
565
|
-
* Auto-Registered
|
|
566
|
-
*/
|
|
567
|
-
declare class HttpServiceProvider {
|
|
568
|
-
private app;
|
|
569
|
-
static priority: number;
|
|
570
|
-
registeredCommands?: (new (app: any, kernel: any) => any)[];
|
|
571
|
-
constructor(app: any);
|
|
572
|
-
register(): void;
|
|
573
|
-
boot(): void;
|
|
574
|
-
}
|
|
575
|
-
//#endregion
|
|
576
|
-
//#region src/Request.d.ts
|
|
577
|
-
declare class Request implements IRequest {
|
|
578
|
-
#private;
|
|
579
|
-
/**
|
|
580
|
-
* The current H3 H3Event instance
|
|
581
|
-
*/
|
|
582
|
-
private readonly event;
|
|
583
|
-
/**
|
|
584
|
-
* The current app instance
|
|
585
|
-
*/
|
|
586
|
-
app: Application;
|
|
587
|
-
/**
|
|
588
|
-
* Parsed request body
|
|
589
|
-
*/
|
|
590
|
-
body: unknown;
|
|
591
|
-
/**
|
|
592
|
-
* Gets route parameters.
|
|
593
|
-
* @returns An object containing route parameters.
|
|
594
|
-
*/
|
|
595
|
-
params: NonNullable<H3Event['context']['params']>;
|
|
596
|
-
/**
|
|
597
|
-
* All of the converted files for the request.
|
|
598
|
-
*/
|
|
599
|
-
protected convertedFiles?: Record<string, UploadedFile | UploadedFile[]>;
|
|
600
|
-
/**
|
|
601
|
-
* Form data from incoming request.
|
|
602
|
-
* @returns The FormRequest object.
|
|
603
|
-
*/
|
|
604
|
-
protected formData: FormRequest;
|
|
605
|
-
/**
|
|
606
|
-
* Request body parameters (POST).
|
|
607
|
-
*
|
|
608
|
-
* @see getPayload() for portability between content types
|
|
609
|
-
*/
|
|
610
|
-
protected request: InputBag;
|
|
611
|
-
/**
|
|
612
|
-
* Uploaded files (FILES).
|
|
613
|
-
*/
|
|
614
|
-
files: FileBag;
|
|
615
|
-
/**
|
|
616
|
-
* Query string parameters (GET).
|
|
617
|
-
*/
|
|
618
|
-
query: InputBag;
|
|
619
|
-
/**
|
|
620
|
-
* Server and execution environment parameters
|
|
621
|
-
*/
|
|
622
|
-
server: ServerBag;
|
|
623
|
-
/**
|
|
624
|
-
* Cookies
|
|
625
|
-
*/
|
|
626
|
-
cookies: InputBag;
|
|
627
|
-
/**
|
|
628
|
-
* The request attributes (parameters parsed from the PATH_INFO, ...).
|
|
629
|
-
*/
|
|
630
|
-
attributes: ParamBag;
|
|
631
|
-
/**
|
|
632
|
-
* Gets the request headers.
|
|
633
|
-
* @returns An object containing request headers.
|
|
634
|
-
*/
|
|
635
|
-
headers: HeaderBag;
|
|
636
|
-
protected content?: ReadableStream | string | false | null;
|
|
637
|
-
protected static formats?: Record<string, string[]> | undefined | null;
|
|
638
|
-
protected static httpMethodParameterOverride: boolean;
|
|
639
|
-
/**
|
|
640
|
-
* List of Acceptable Content Types
|
|
641
|
-
*/
|
|
642
|
-
private acceptableContentTypes;
|
|
643
|
-
constructor(
|
|
644
|
-
/**
|
|
645
|
-
* The current H3 H3Event instance
|
|
646
|
-
*/
|
|
647
|
-
event: H3Event,
|
|
648
|
-
/**
|
|
649
|
-
* The current app instance
|
|
650
|
-
*/
|
|
651
|
-
app: Application);
|
|
652
|
-
/**
|
|
653
|
-
* Factory method to create a Request instance from an H3Event.
|
|
654
|
-
*/
|
|
655
|
-
static create(
|
|
656
|
-
/**
|
|
657
|
-
* The current H3 H3Event instance
|
|
658
|
-
*/
|
|
659
|
-
event: H3Event,
|
|
660
|
-
/**
|
|
661
|
-
* The current app instance
|
|
662
|
-
*/
|
|
663
|
-
app: Application): Promise<Request>;
|
|
664
|
-
/**
|
|
665
|
-
* Sets the parameters for this request.
|
|
666
|
-
*
|
|
667
|
-
* This method also re-initializes all properties.
|
|
668
|
-
*
|
|
669
|
-
* @param attributes
|
|
670
|
-
* @param cookies The COOKIE parameters
|
|
671
|
-
* @param files The FILES parameters
|
|
672
|
-
* @param server The SERVER parameters
|
|
673
|
-
* @param content The raw body data
|
|
674
|
-
*/
|
|
675
|
-
initialize(): Promise<void>;
|
|
676
|
-
private setBody;
|
|
677
|
-
/**
|
|
678
|
-
* Retrieve all data from the instance (query + body).
|
|
679
|
-
*/
|
|
680
|
-
all<T = Record<string, any>>(keys?: string | string[]): T;
|
|
681
|
-
/**
|
|
682
|
-
* Retrieve an input item from the request.
|
|
683
|
-
*
|
|
684
|
-
* @param key
|
|
685
|
-
* @param defaultValue
|
|
686
|
-
* @returns
|
|
687
|
-
*/
|
|
688
|
-
input<K extends string | undefined>(key?: K, defaultValue?: any): K extends undefined ? RequestObject : any;
|
|
689
|
-
/**
|
|
690
|
-
* Retrieve a file from the request.
|
|
691
|
-
*
|
|
692
|
-
* By default a single `UploadedFile` instance will always be returned by
|
|
693
|
-
* the method (first file in property when there are multiple), unless
|
|
694
|
-
* the `expectArray` parameter is set to true, in which case, the method
|
|
695
|
-
* returns an `UploadedFile[]` array.
|
|
696
|
-
*
|
|
697
|
-
* @param key
|
|
698
|
-
* @param defaultValue
|
|
699
|
-
* @param expectArray set to true to return an `UploadedFile[]` array.
|
|
700
|
-
* @returns
|
|
701
|
-
*/
|
|
702
|
-
file<K extends string | undefined = undefined, E extends boolean | undefined = undefined>(key?: K, defaultValue?: any, expectArray?: E): K extends undefined ? Record<string, E extends true ? UploadedFile[] : UploadedFile> : E extends true ? UploadedFile[] : UploadedFile;
|
|
703
|
-
/**
|
|
704
|
-
* Determine if the uploaded data contains a file.
|
|
705
|
-
*
|
|
706
|
-
* @param key
|
|
707
|
-
* @return boolean
|
|
708
|
-
*/
|
|
709
|
-
hasFile(key: string): boolean;
|
|
710
|
-
/**
|
|
711
|
-
* Check that the given file is a valid file instance.
|
|
712
|
-
*
|
|
713
|
-
* @param file
|
|
714
|
-
* @return boolean
|
|
715
|
-
*/
|
|
716
|
-
protected isValidFile(file: UploadedFile): boolean;
|
|
717
|
-
/**
|
|
718
|
-
* Get an object with all the files on the request.
|
|
719
|
-
*/
|
|
720
|
-
allFiles(): Record<string, UploadedFile | UploadedFile[]>;
|
|
721
|
-
/**
|
|
722
|
-
* Extract and convert uploaded files from FormData.
|
|
723
|
-
*/
|
|
724
|
-
convertUploadedFiles(files: Record<string, UploadedFile | UploadedFile[]>): Record<string, UploadedFile | UploadedFile[]>;
|
|
725
|
-
/**
|
|
726
|
-
* Determine if the data contains a given key.
|
|
727
|
-
*
|
|
728
|
-
* @param keys
|
|
729
|
-
* @returns
|
|
730
|
-
*/
|
|
731
|
-
has(keys: string[] | string): boolean;
|
|
732
|
-
/**
|
|
733
|
-
* Determine if the instance is missing a given key.
|
|
734
|
-
*/
|
|
735
|
-
missing(key: string | string[]): boolean;
|
|
736
|
-
/**
|
|
737
|
-
* Get a subset containing the provided keys with values from the instance data.
|
|
738
|
-
*
|
|
739
|
-
* @param keys
|
|
740
|
-
* @returns
|
|
741
|
-
*/
|
|
742
|
-
only<T = Record<string, any>>(keys: string[]): T;
|
|
743
|
-
/**
|
|
744
|
-
* Get all of the data except for a specified array of items.
|
|
745
|
-
*
|
|
746
|
-
* @param keys
|
|
747
|
-
* @returns
|
|
748
|
-
*/
|
|
749
|
-
except<T = Record<string, any>>(keys: string[]): T;
|
|
750
|
-
/**
|
|
751
|
-
* Merges new input data into the current request's input source.
|
|
752
|
-
*
|
|
753
|
-
* @param input - An object containing key-value pairs to merge.
|
|
754
|
-
* @returns this - For fluent chaining.
|
|
755
|
-
*/
|
|
756
|
-
merge(input: Record<string, any>): this;
|
|
757
|
-
/**
|
|
758
|
-
* Merge new input into the request's input, but only when that key is missing from the request.
|
|
759
|
-
*
|
|
760
|
-
* @param input
|
|
761
|
-
*/
|
|
762
|
-
mergeIfMissing(input: Record<string, any>): this;
|
|
763
|
-
/**
|
|
764
|
-
* Get the keys for all of the input and files.
|
|
765
|
-
*/
|
|
766
|
-
keys(): string[];
|
|
767
|
-
/**
|
|
768
|
-
* Determine if the request is sending JSON.
|
|
769
|
-
*
|
|
770
|
-
* @return bool
|
|
771
|
-
*/
|
|
772
|
-
isJson(): boolean;
|
|
773
|
-
/**
|
|
774
|
-
* Determine if the current request probably expects a JSON response.
|
|
775
|
-
*
|
|
776
|
-
* @returns
|
|
777
|
-
*/
|
|
778
|
-
expectsJson(): boolean;
|
|
779
|
-
/**
|
|
780
|
-
* Determine if the current request is asking for JSON.
|
|
781
|
-
*
|
|
782
|
-
* @returns
|
|
783
|
-
*/
|
|
784
|
-
wantsJson(): boolean;
|
|
785
|
-
/**
|
|
786
|
-
* Gets a list of content types acceptable by the client browser in preferable order.
|
|
787
|
-
* @returns {string[]}
|
|
788
|
-
*/
|
|
789
|
-
getAcceptableContentTypes(): string[];
|
|
790
|
-
/**
|
|
791
|
-
* Determine if the request is the result of a PJAX call.
|
|
792
|
-
*
|
|
793
|
-
* @return bool
|
|
794
|
-
*/
|
|
795
|
-
pjax(): boolean;
|
|
796
|
-
/**
|
|
797
|
-
* Returns true if the request is an XMLHttpRequest (AJAX).
|
|
798
|
-
*
|
|
799
|
-
* @alias isXmlHttpRequest()
|
|
800
|
-
* @returns {boolean}
|
|
801
|
-
*/
|
|
802
|
-
ajax(): boolean;
|
|
803
|
-
/**
|
|
804
|
-
* Returns true if the request is an XMLHttpRequest (AJAX).
|
|
805
|
-
*/
|
|
806
|
-
isXmlHttpRequest(): boolean;
|
|
807
|
-
/**
|
|
808
|
-
* Returns the value of the requested header.
|
|
809
|
-
*/
|
|
810
|
-
getHeader(name: string): string | undefined | null;
|
|
811
|
-
/**
|
|
812
|
-
* Checks if the request method is of specified type.
|
|
813
|
-
*
|
|
814
|
-
* @param method Uppercase request method (GET, POST etc)
|
|
815
|
-
*/
|
|
816
|
-
isMethod(method: string): boolean;
|
|
817
|
-
/**
|
|
818
|
-
* Checks whether or not the method is safe.
|
|
819
|
-
*
|
|
820
|
-
* @see https://tools.ietf.org/html/rfc7231#section-4.2.1
|
|
821
|
-
*/
|
|
822
|
-
isMethodSafe(): boolean;
|
|
823
|
-
/**
|
|
824
|
-
* Checks whether or not the method is idempotent.
|
|
825
|
-
*/
|
|
826
|
-
isMethodIdempotent(): boolean;
|
|
827
|
-
/**
|
|
828
|
-
* Checks whether the method is cacheable or not.
|
|
829
|
-
*
|
|
830
|
-
* @see https://tools.ietf.org/html/rfc7231#section-4.2.3
|
|
831
|
-
*/
|
|
832
|
-
isMethodCacheable(): boolean;
|
|
833
|
-
/**
|
|
834
|
-
* Initializes HTTP request formats.
|
|
835
|
-
*/
|
|
836
|
-
protected static initializeFormats(): void;
|
|
837
|
-
/**
|
|
838
|
-
* Gets the request "intended" method.
|
|
839
|
-
*
|
|
840
|
-
* If the X-HTTP-Method-Override header is set, and if the method is a POST,
|
|
841
|
-
* then it is used to determine the "real" intended HTTP method.
|
|
842
|
-
*
|
|
843
|
-
* The _method request parameter can also be used to determine the HTTP method,
|
|
844
|
-
* but only if enableHttpMethodParameterOverride() has been called.
|
|
845
|
-
*
|
|
846
|
-
* The method is always an uppercased string.
|
|
847
|
-
*
|
|
848
|
-
* @see getRealMethod()
|
|
849
|
-
*/
|
|
850
|
-
getMethod(): RequestMethod;
|
|
851
|
-
/**
|
|
852
|
-
* Gets the "real" request method.
|
|
853
|
-
*
|
|
854
|
-
* @see getMethod()
|
|
855
|
-
*/
|
|
856
|
-
getRealMethod(): RequestMethod;
|
|
857
|
-
/**
|
|
858
|
-
* Get the client IP address.
|
|
859
|
-
*/
|
|
860
|
-
ip(): string | undefined;
|
|
861
|
-
/**
|
|
862
|
-
* Get a URI instance for the request.
|
|
863
|
-
*/
|
|
864
|
-
uri(): Url;
|
|
865
|
-
/**
|
|
866
|
-
* Get the full URL for the request.
|
|
867
|
-
*/
|
|
868
|
-
fullUrl(): string;
|
|
869
|
-
/**
|
|
870
|
-
* Return the Request instance.
|
|
871
|
-
*/
|
|
872
|
-
instance(): this;
|
|
873
|
-
/**
|
|
874
|
-
* Get the request method.
|
|
875
|
-
*/
|
|
876
|
-
method(): RequestMethod;
|
|
877
|
-
/**
|
|
878
|
-
* Get the JSON payload for the request.
|
|
879
|
-
*
|
|
880
|
-
* @param key
|
|
881
|
-
* @param defaultValue
|
|
882
|
-
* @return {InputBag}
|
|
883
|
-
*/
|
|
884
|
-
json<K extends string | undefined = undefined>(key?: string, defaultValue?: any): K extends undefined ? InputBag : any;
|
|
885
|
-
/**
|
|
886
|
-
* Get the input source for the request.
|
|
887
|
-
*
|
|
888
|
-
* @return {InputBag}
|
|
889
|
-
*/
|
|
890
|
-
protected getInputSource(): InputBag;
|
|
891
|
-
/**
|
|
892
|
-
* Returns the request body content.
|
|
893
|
-
*
|
|
894
|
-
* @param asStream If true, returns a ReadableStream instead of the parsed string
|
|
895
|
-
* @return {string | ReadableStream | Promise<string | ReadableStream>}
|
|
896
|
-
*/
|
|
897
|
-
getContent(asStream?: boolean): string | ReadableStream;
|
|
898
|
-
/**
|
|
899
|
-
* Gets a "parameter" value from any bag.
|
|
900
|
-
*
|
|
901
|
-
* This method is mainly useful for libraries that want to provide some flexibility. If you don't need the
|
|
902
|
-
* flexibility in controllers, it is better to explicitly get request parameters from the appropriate
|
|
903
|
-
* public property instead (attributes, query, request).
|
|
904
|
-
*
|
|
905
|
-
* Order of precedence: PATH (routing placeholders or custom attributes), GET, POST
|
|
906
|
-
*
|
|
907
|
-
* @internal use explicit input sources instead
|
|
908
|
-
*/
|
|
909
|
-
get(key: string, defaultValue?: any): any;
|
|
910
|
-
/**
|
|
911
|
-
* Enables support for the _method request parameter to determine the intended HTTP method.
|
|
912
|
-
*
|
|
913
|
-
* Be warned that enabling this feature might lead to CSRF issues in your code.
|
|
914
|
-
* Check that you are using CSRF tokens when required.
|
|
915
|
-
* If the HTTP method parameter override is enabled, an html-form with method "POST" can be altered
|
|
916
|
-
* and used to send a "PUT" or "DELETE" request via the _method request parameter.
|
|
917
|
-
* If these methods are not protected against CSRF, this presents a possible vulnerability.
|
|
918
|
-
*
|
|
919
|
-
* The HTTP method can only be overridden when the real HTTP method is POST.
|
|
920
|
-
*/
|
|
921
|
-
static enableHttpMethodParameterOverride(): void;
|
|
922
|
-
/**
|
|
923
|
-
* Checks whether support for the _method request parameter is enabled.
|
|
924
|
-
*/
|
|
925
|
-
static getHttpMethodParameterOverride(): boolean;
|
|
926
|
-
/**
|
|
927
|
-
* Dump the items.
|
|
928
|
-
*
|
|
929
|
-
* @param keys
|
|
930
|
-
* @return this
|
|
931
|
-
*/
|
|
932
|
-
dump(...keys: any[]): this;
|
|
933
|
-
/**
|
|
934
|
-
* Get the base event
|
|
935
|
-
*/
|
|
936
|
-
getEvent(): H3Event;
|
|
937
|
-
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
938
|
-
}
|
|
939
|
-
//#endregion
|
|
940
|
-
//#region src/Resources/JsonResource.d.ts
|
|
941
|
-
interface Resource {
|
|
942
|
-
[key: string]: any;
|
|
943
|
-
pagination?: {
|
|
944
|
-
from?: number | undefined;
|
|
945
|
-
to?: number | undefined;
|
|
946
|
-
perPage?: number | undefined;
|
|
947
|
-
total?: number | undefined;
|
|
948
|
-
} | undefined;
|
|
949
|
-
}
|
|
950
|
-
type BodyResource = Resource & {
|
|
951
|
-
data: Omit<Resource, 'pagination'>;
|
|
952
|
-
meta?: {
|
|
953
|
-
pagination?: Resource['pagination'];
|
|
954
|
-
} | undefined;
|
|
955
|
-
};
|
|
956
|
-
/**
|
|
957
|
-
* Class to render API resource
|
|
958
|
-
*/
|
|
959
|
-
declare class JsonResource<R$1 extends Resource = any> {
|
|
960
|
-
#private;
|
|
961
|
-
protected event: H3Event;
|
|
962
|
-
/**
|
|
963
|
-
* The request instance
|
|
964
|
-
*/
|
|
965
|
-
request: H3Event<EventHandlerRequest>['req'];
|
|
966
|
-
/**
|
|
967
|
-
* The response instance
|
|
968
|
-
*/
|
|
969
|
-
response: H3Event['res'];
|
|
970
|
-
/**
|
|
971
|
-
* The data to send to the client
|
|
972
|
-
*/
|
|
973
|
-
resource: R$1;
|
|
974
|
-
/**
|
|
975
|
-
* The final response data object
|
|
976
|
-
*/
|
|
977
|
-
body: BodyResource;
|
|
978
|
-
/**
|
|
979
|
-
* Flag to track if response should be sent automatically
|
|
980
|
-
*/
|
|
981
|
-
private shouldSend;
|
|
982
|
-
/**
|
|
983
|
-
* Flag to track if response has been sent
|
|
984
|
-
*/
|
|
985
|
-
private responseSent;
|
|
986
|
-
/**
|
|
987
|
-
* Declare that this includes R's properties
|
|
988
|
-
*/
|
|
989
|
-
[key: string]: any;
|
|
990
|
-
/**
|
|
991
|
-
* @param req The request instance
|
|
992
|
-
* @param res The response instance
|
|
993
|
-
* @param rsc The data to send to the client
|
|
994
|
-
*/
|
|
995
|
-
constructor(event: H3Event, rsc: R$1);
|
|
996
|
-
/**
|
|
997
|
-
* Return the data in the expected format
|
|
998
|
-
*
|
|
999
|
-
* @returns
|
|
1000
|
-
*/
|
|
1001
|
-
data(): Resource;
|
|
1002
|
-
/**
|
|
1003
|
-
* Build the response object
|
|
1004
|
-
* @returns this
|
|
1005
|
-
*/
|
|
1006
|
-
json(): this;
|
|
1007
|
-
/**
|
|
1008
|
-
* Add context data to the response object
|
|
1009
|
-
* @param data Context data
|
|
1010
|
-
* @returns this
|
|
1011
|
-
*/
|
|
1012
|
-
additional<X extends {
|
|
1013
|
-
[key: string]: any;
|
|
1014
|
-
}>(data: X): this;
|
|
1015
|
-
/**
|
|
1016
|
-
* Send the output to the client
|
|
1017
|
-
* @returns this
|
|
1018
|
-
*/
|
|
1019
|
-
send(): this;
|
|
1020
|
-
/**
|
|
1021
|
-
* Set the status code for this response
|
|
1022
|
-
* @param code Status code
|
|
1023
|
-
* @returns this
|
|
1024
|
-
*/
|
|
1025
|
-
status(code: number): this;
|
|
1026
|
-
/**
|
|
1027
|
-
* Check if send should be triggered automatically
|
|
1028
|
-
*/
|
|
1029
|
-
private checkSend;
|
|
1030
|
-
}
|
|
1031
|
-
//#endregion
|
|
1032
|
-
//#region src/Resources/ApiResource.d.ts
|
|
1033
|
-
declare function ApiResource(instance: JsonResource): JsonResource<any>;
|
|
1034
|
-
//#endregion
|
|
1035
|
-
//#region src/Response.d.ts
|
|
1036
|
-
declare class Response implements IResponse {
|
|
1037
|
-
/**
|
|
1038
|
-
* The current app instance
|
|
1039
|
-
*/
|
|
1040
|
-
app: Application;
|
|
1041
|
-
/**
|
|
1042
|
-
* The current H3 H3Event instance
|
|
1043
|
-
*/
|
|
1044
|
-
private readonly event;
|
|
1045
|
-
private statusCode;
|
|
1046
|
-
private headers;
|
|
1047
|
-
constructor(event: H3Event,
|
|
1048
|
-
/**
|
|
1049
|
-
* The current app instance
|
|
1050
|
-
*/
|
|
1051
|
-
app: Application);
|
|
1052
|
-
/**
|
|
1053
|
-
* Set HTTP status code.
|
|
1054
|
-
*/
|
|
1055
|
-
setStatusCode(code: number): this;
|
|
1056
|
-
/**
|
|
1057
|
-
* Set a header.
|
|
1058
|
-
*/
|
|
1059
|
-
setHeader(name: string, value: string): this;
|
|
1060
|
-
html(content: string): HTTPResponse;
|
|
1061
|
-
/**
|
|
1062
|
-
* Send a JSON response.
|
|
1063
|
-
*/
|
|
1064
|
-
json<T = unknown>(data: T): T;
|
|
1065
|
-
/**
|
|
1066
|
-
* Send plain text.
|
|
1067
|
-
*/
|
|
1068
|
-
text(data: string): string;
|
|
1069
|
-
/**
|
|
1070
|
-
* Redirect to another URL.
|
|
1071
|
-
*/
|
|
1072
|
-
redirect(location: string, status?: number, statusText?: string | undefined): HTTPResponse;
|
|
1073
|
-
/**
|
|
1074
|
-
* Apply headers before sending response.
|
|
1075
|
-
*/
|
|
1076
|
-
private applyHeaders;
|
|
1077
|
-
/**
|
|
1078
|
-
* Get the base event
|
|
1079
|
-
*/
|
|
1080
|
-
getEvent(): H3Event;
|
|
1081
|
-
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
1082
|
-
}
|
|
1083
|
-
//#endregion
|
|
1084
|
-
export { ApiResource, BadRequestException, FileBag, FireCommand, FormRequest, HeaderBag, HttpContext, HttpServiceProvider, InputBag, JsonResource, LogRequests, Middleware, ParamBag, Request, Resource, Response, ServerBag, SuspiciousOperationException, UnexpectedValueException, UploadedFile };
|