@adonisjs/http-server 8.0.0-next.1 → 8.0.0-next.10
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/build/chunk-2QM3D5BN.js +87 -0
- package/build/chunk-5PWHBE2E.js +128 -0
- package/build/chunk-QDK57QGB.js +1176 -0
- package/build/{chunk-HMYAZG76.js → chunk-YBLFT4O6.js} +1146 -1663
- package/build/factories/http_context.d.ts +2 -1
- package/build/factories/http_server.d.ts +7 -0
- package/build/factories/main.js +33 -5
- package/build/factories/qs_parser_factory.d.ts +3 -2
- package/build/factories/request.d.ts +1 -0
- package/build/factories/response.d.ts +1 -0
- package/build/factories/router.d.ts +1 -0
- package/build/factories/server_factory.d.ts +1 -0
- package/build/factories/url_builder_factory.d.ts +3 -2
- package/build/index.d.ts +4 -1
- package/build/index.js +97 -42
- package/build/src/client/helpers.d.ts +37 -0
- package/build/src/client/types.d.ts +203 -0
- package/build/src/client/url_builder.d.ts +15 -0
- package/build/src/client/url_builder.js +12 -0
- package/build/src/cookies/client.d.ts +61 -3
- package/build/src/cookies/drivers/encrypted.d.ts +13 -0
- package/build/src/cookies/drivers/plain.d.ts +9 -0
- package/build/src/cookies/drivers/signed.d.ts +13 -0
- package/build/src/cookies/parser.d.ts +18 -0
- package/build/src/cookies/serializer.d.ts +21 -2
- package/build/src/debug.d.ts +13 -0
- package/build/src/define_config.d.ts +20 -4
- package/build/src/define_middleware.d.ts +20 -4
- package/build/src/errors.d.ts +60 -5
- package/build/src/exception_handler.d.ts +93 -39
- package/build/src/helpers.d.ts +57 -0
- package/build/src/helpers.js +9 -1
- package/build/src/http_context/local_storage.d.ts +17 -0
- package/build/src/http_context/main.d.ts +68 -10
- package/build/src/qs.d.ts +30 -2
- package/build/src/redirect.d.ts +84 -12
- package/build/src/request.d.ts +118 -12
- package/build/src/response.d.ts +416 -203
- package/build/src/response_status.d.ts +14 -0
- package/build/src/router/brisk.d.ts +15 -4
- package/build/src/router/executor.d.ts +4 -0
- package/build/src/router/factories/use_return_value.d.ts +5 -0
- package/build/src/router/group.d.ts +18 -1
- package/build/src/router/legacy/url_builder.d.ts +14 -14
- package/build/src/router/main.d.ts +79 -22
- package/build/src/router/matchers.d.ts +3 -0
- package/build/src/router/resource.d.ts +34 -1
- package/build/src/router/route.d.ts +28 -3
- package/build/src/router/signed_url_builder.d.ts +4 -8
- package/build/src/router/store.d.ts +9 -0
- package/build/src/server/factories/middleware_handler.d.ts +10 -1
- package/build/src/server/factories/route_finder.d.ts +13 -3
- package/build/src/server/factories/write_response.d.ts +9 -2
- package/build/src/server/main.d.ts +77 -23
- package/build/src/tracing_channels.d.ts +4 -4
- package/build/src/types/middleware.d.ts +34 -9
- package/build/src/types/qs.d.ts +5 -0
- package/build/src/types/request.d.ts +1 -1
- package/build/src/types/response.d.ts +14 -6
- package/build/src/types/route.d.ts +42 -42
- package/build/src/types/server.d.ts +26 -11
- package/build/src/types/tracing_channels.d.ts +21 -3
- package/build/src/types/url_builder.d.ts +10 -135
- package/build/src/utils.d.ts +71 -6
- package/package.json +26 -22
- package/build/chunk-ASX56VAK.js +0 -76
- package/build/src/router/url_builder.d.ts +0 -14
package/build/src/redirect.d.ts
CHANGED
|
@@ -2,40 +2,112 @@ import type { IncomingMessage } from 'node:http';
|
|
|
2
2
|
import type { Qs } from './qs.ts';
|
|
3
3
|
import type { Response } from './response.ts';
|
|
4
4
|
import type { Router } from './router/main.ts';
|
|
5
|
-
import type { RoutesList, URLOptions, GetRoutesForMethod, RouteBuilderArguments } from './types/url_builder.ts';
|
|
5
|
+
import type { RoutesList, LookupList, URLOptions, GetRoutesForMethod, RouteBuilderArguments } from './types/url_builder.ts';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Provides a fluent API for constructing HTTP redirect responses.
|
|
8
|
+
*
|
|
9
|
+
* The Redirect class allows you to build redirects with custom status codes,
|
|
10
|
+
* query string forwarding, and route-based URL generation. It supports both
|
|
11
|
+
* direct URL redirects and route-based redirects using registered route names.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* // Basic redirect
|
|
16
|
+
* return response.redirect('https://example.com')
|
|
17
|
+
*
|
|
18
|
+
* // Redirect to a route
|
|
19
|
+
* return response.redirect().toRoute('users.show', { id: 1 })
|
|
20
|
+
*
|
|
21
|
+
* // Redirect with status code and query string
|
|
22
|
+
* return response.redirect()
|
|
23
|
+
* .status(301)
|
|
24
|
+
* .withQs({ utm_source: 'newsletter' })
|
|
25
|
+
* .toPath('/dashboard')
|
|
26
|
+
* ```
|
|
8
27
|
*/
|
|
9
28
|
export declare class Redirect {
|
|
10
29
|
#private;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new Redirect instance for handling HTTP redirects
|
|
32
|
+
* @param request - Node.js incoming HTTP request
|
|
33
|
+
* @param response - AdonisJS response instance
|
|
34
|
+
* @param router - AdonisJS router instance
|
|
35
|
+
* @param qs - Query string parser instance
|
|
36
|
+
*/
|
|
11
37
|
constructor(request: IncomingMessage, response: Response, router: Router, qs: Qs);
|
|
12
38
|
/**
|
|
13
|
-
*
|
|
39
|
+
* Sets a custom HTTP status code for the redirect response
|
|
40
|
+
* @param statusCode - HTTP status code to use (e.g., 301, 302, 307)
|
|
41
|
+
* @returns {this} The Redirect instance for method chaining
|
|
14
42
|
*/
|
|
15
43
|
status(statusCode: number): this;
|
|
16
44
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
45
|
+
* Clears any query string values previously added using the withQs method
|
|
46
|
+
* @returns {this} The Redirect instance for method chaining
|
|
19
47
|
*/
|
|
20
48
|
clearQs(): this;
|
|
21
49
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
50
|
+
* Forwards the current request's query string to the redirect URL
|
|
51
|
+
*
|
|
52
|
+
* Use this overload when you want to preserve all existing query parameters
|
|
53
|
+
* from the current request in the redirect URL.
|
|
54
|
+
*
|
|
55
|
+
* @returns The Redirect instance for method chaining
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* // If current URL is '/search?q=hello&page=2'
|
|
60
|
+
* response.redirect().withQs().toPath('/results')
|
|
61
|
+
* // Redirects to: '/results?q=hello&page=2'
|
|
62
|
+
* ```
|
|
25
63
|
*/
|
|
26
64
|
withQs(): this;
|
|
65
|
+
/**
|
|
66
|
+
* Adds multiple query string parameters to the redirect URL
|
|
67
|
+
*
|
|
68
|
+
* Use this overload when you want to add several query parameters at once
|
|
69
|
+
* using an object with key-value pairs.
|
|
70
|
+
*
|
|
71
|
+
* @param values - Object containing query parameter names and values
|
|
72
|
+
* @returns The Redirect instance for method chaining
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* response.redirect().withQs({ page: 1, sort: 'name' }).toPath('/users')
|
|
77
|
+
* // Redirects to: '/users?page=1&sort=name'
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
27
80
|
withQs(values: Record<string, any>): this;
|
|
81
|
+
/**
|
|
82
|
+
* Adds a single query string parameter to the redirect URL
|
|
83
|
+
*
|
|
84
|
+
* Use this overload when you want to add just one query parameter
|
|
85
|
+
* with a specific name and value.
|
|
86
|
+
*
|
|
87
|
+
* @param name - The query parameter name
|
|
88
|
+
* @param value - The query parameter value
|
|
89
|
+
* @returns The Redirect instance for method chaining
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* response.redirect().withQs('success', 'true').toPath('/dashboard')
|
|
94
|
+
* // Redirects to: '/dashboard?success=true'
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
28
97
|
withQs(name: string, value: any): this;
|
|
29
98
|
/**
|
|
30
|
-
*
|
|
99
|
+
* Redirects to the previous path using the Referer header
|
|
100
|
+
* Falls back to '/' if no referrer is found
|
|
31
101
|
*/
|
|
32
102
|
back(): void;
|
|
33
103
|
/**
|
|
34
|
-
*
|
|
104
|
+
* Redirects to a route using its identifier (name, pattern, or handler reference)
|
|
105
|
+
* @param args - Route identifier, parameters, and options for URL building
|
|
35
106
|
*/
|
|
36
|
-
toRoute<Identifier extends keyof GetRoutesForMethod<'GET'> & string>(...args: RouteBuilderArguments<
|
|
107
|
+
toRoute<Identifier extends keyof GetRoutesForMethod<RoutesList, 'GET'> & string>(...args: RoutesList extends LookupList ? RouteBuilderArguments<Identifier, RoutesList['GET'][Identifier], URLOptions> : []): void;
|
|
37
108
|
/**
|
|
38
|
-
*
|
|
109
|
+
* Redirects to a specific URL path
|
|
110
|
+
* @param url - Target URL path for redirection
|
|
39
111
|
*/
|
|
40
112
|
toPath(url: string): void;
|
|
41
113
|
}
|
package/build/src/request.d.ts
CHANGED
|
@@ -15,25 +15,49 @@ import type { HttpContext } from './http_context/main.ts';
|
|
|
15
15
|
*/
|
|
16
16
|
export declare class Request extends Macroable {
|
|
17
17
|
#private;
|
|
18
|
+
/** Native Node.js incoming message instance */
|
|
18
19
|
request: IncomingMessage;
|
|
20
|
+
/** Native Node.js server response instance */
|
|
19
21
|
response: ServerResponse;
|
|
20
22
|
/**
|
|
21
|
-
* Parsed URL with query string stored as a string
|
|
23
|
+
* Parsed URL with query string stored as a string and decode flag
|
|
22
24
|
*/
|
|
23
25
|
parsedUrl: {
|
|
26
|
+
/** The pathname portion of the URL */
|
|
24
27
|
pathname: string;
|
|
28
|
+
/** The query string portion of the URL */
|
|
25
29
|
query: string;
|
|
30
|
+
/** Flag indicating whether parameters should be decoded */
|
|
26
31
|
shouldDecodeParam: boolean;
|
|
27
32
|
};
|
|
28
33
|
/**
|
|
29
|
-
*
|
|
30
|
-
* reference
|
|
34
|
+
* HTTP context reference - creates a circular reference when set by the context
|
|
31
35
|
*/
|
|
32
36
|
ctx?: HttpContext;
|
|
33
|
-
constructor(request: IncomingMessage, response: ServerResponse, encryption: Encryption, config: RequestConfig, qsParser: Qs);
|
|
34
37
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
38
|
+
* Creates a new Request instance wrapping the native Node.js HTTP request
|
|
39
|
+
* @param request - Native Node.js incoming message instance
|
|
40
|
+
* @param response - Native Node.js server response instance
|
|
41
|
+
* @param encryption - Encryption module for cookie and URL signing
|
|
42
|
+
* @param config - Request configuration options
|
|
43
|
+
* @param qsParser - Query string parser instance
|
|
44
|
+
*/
|
|
45
|
+
constructor(
|
|
46
|
+
/** Native Node.js incoming message instance */
|
|
47
|
+
request: IncomingMessage,
|
|
48
|
+
/** Native Node.js server response instance */
|
|
49
|
+
response: ServerResponse, encryption: Encryption, config: RequestConfig, qsParser: Qs);
|
|
50
|
+
/**
|
|
51
|
+
* Returns the request ID from the `x-request-id` header.
|
|
52
|
+
*
|
|
53
|
+
* If the header doesn't exist and request ID generation is enabled,
|
|
54
|
+
* a new UUID will be generated and added to the request headers.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* const requestId = request.id()
|
|
59
|
+
* console.log(requestId) // '550e8400-e29b-41d4-a716-446655440000'
|
|
60
|
+
* ```
|
|
37
61
|
*/
|
|
38
62
|
id(): string | undefined;
|
|
39
63
|
/**
|
|
@@ -43,44 +67,57 @@ export declare class Request extends Macroable {
|
|
|
43
67
|
*
|
|
44
68
|
* This method is supposed to be invoked by the body parser and must be called only
|
|
45
69
|
* once. For further mutations make use of `updateBody` method.
|
|
70
|
+
* @param body - Parsed request body data
|
|
71
|
+
* @returns {void}
|
|
46
72
|
*/
|
|
47
73
|
setInitialBody(body: Record<string, any>): void;
|
|
48
74
|
/**
|
|
49
75
|
* Update the request body with new data object. The `all` property
|
|
50
76
|
* will be re-computed by merging the query string and request
|
|
51
77
|
* body.
|
|
78
|
+
* @param body - New request body data to set
|
|
79
|
+
* @returns {void}
|
|
52
80
|
*/
|
|
53
81
|
updateBody(body: Record<string, any>): void;
|
|
54
82
|
/**
|
|
55
83
|
* Update the request raw body. Bodyparser sets this when unable to parse
|
|
56
84
|
* the request body or when request is multipart/form-data.
|
|
85
|
+
* @param rawBody - Raw request body as string
|
|
86
|
+
* @returns {void}
|
|
57
87
|
*/
|
|
58
88
|
updateRawBody(rawBody: string): void;
|
|
59
89
|
/**
|
|
60
90
|
* Update the query string with the new data object. The `all` property
|
|
61
91
|
* will be re-computed by merging the query and the request body.
|
|
92
|
+
* @param data - New query string data to set
|
|
93
|
+
* @returns {void}
|
|
62
94
|
*/
|
|
63
95
|
updateQs(data: Record<string, any>): void;
|
|
64
96
|
/**
|
|
65
97
|
* Returns route params
|
|
98
|
+
* @returns {Record<string, any>} Object containing route parameters
|
|
66
99
|
*/
|
|
67
100
|
params(): Record<string, any>;
|
|
68
101
|
/**
|
|
69
102
|
* Returns the query string object by reference
|
|
103
|
+
* @returns {Record<string, any>} Object containing parsed query string parameters
|
|
70
104
|
*/
|
|
71
105
|
qs(): Record<string, any>;
|
|
72
106
|
/**
|
|
73
107
|
* Returns reference to the request body
|
|
108
|
+
* @returns {Record<string, any>} Object containing parsed request body
|
|
74
109
|
*/
|
|
75
110
|
body(): Record<string, any>;
|
|
76
111
|
/**
|
|
77
112
|
* Returns reference to the merged copy of request body
|
|
78
113
|
* and query string
|
|
114
|
+
* @returns {Record<string, any>} Object containing merged request body and query parameters
|
|
79
115
|
*/
|
|
80
116
|
all(): Record<string, any>;
|
|
81
117
|
/**
|
|
82
118
|
* Returns reference to the merged copy of original request
|
|
83
119
|
* query string and body
|
|
120
|
+
* @returns {Record<string, any>} Object containing original merged request data
|
|
84
121
|
*/
|
|
85
122
|
original(): Record<string, any>;
|
|
86
123
|
/**
|
|
@@ -88,6 +125,7 @@ export declare class Request extends Macroable {
|
|
|
88
125
|
*
|
|
89
126
|
* Ideally you must be dealing with the parsed body accessed using [[input]], [[all]] or
|
|
90
127
|
* [[post]] methods. The `raw` body is always a string.
|
|
128
|
+
* @returns {string | null} Raw request body as string or null if not set
|
|
91
129
|
*/
|
|
92
130
|
raw(): string | null;
|
|
93
131
|
/**
|
|
@@ -101,6 +139,9 @@ export declare class Request extends Macroable {
|
|
|
101
139
|
* // with default value
|
|
102
140
|
* request.input('username', 'virk')
|
|
103
141
|
* ```
|
|
142
|
+
* @param key - Key to lookup in request data
|
|
143
|
+
* @param defaultValue - Default value when key is not found
|
|
144
|
+
* @returns Value from request data or default value
|
|
104
145
|
*/
|
|
105
146
|
input(key: string, defaultValue?: any): any;
|
|
106
147
|
/**
|
|
@@ -113,6 +154,9 @@ export declare class Request extends Macroable {
|
|
|
113
154
|
* // with default value
|
|
114
155
|
* request.param('id', 1)
|
|
115
156
|
* ```
|
|
157
|
+
* @param key - Parameter key to lookup
|
|
158
|
+
* @param defaultValue - Default value when parameter is not found
|
|
159
|
+
* @returns Value from route parameters or default value
|
|
116
160
|
*/
|
|
117
161
|
param(key: string, defaultValue?: any): any;
|
|
118
162
|
/**
|
|
@@ -122,6 +166,8 @@ export declare class Request extends Macroable {
|
|
|
122
166
|
* ```js
|
|
123
167
|
* request.except(['_csrf'])
|
|
124
168
|
* ```
|
|
169
|
+
* @param keys - Array of keys to exclude from the result
|
|
170
|
+
* @returns {Record<string, any>} Object with all request data except specified keys
|
|
125
171
|
*/
|
|
126
172
|
except(keys: string[]): Record<string, any>;
|
|
127
173
|
/**
|
|
@@ -131,6 +177,8 @@ export declare class Request extends Macroable {
|
|
|
131
177
|
* ```js
|
|
132
178
|
* request.only(['username', 'age'])
|
|
133
179
|
* ```
|
|
180
|
+
* @param keys - Array of keys to include in the result
|
|
181
|
+
* @returns {{ [K in T]: any }} Object with only the specified keys from request data
|
|
134
182
|
*/
|
|
135
183
|
only<T extends string>(keys: T[]): {
|
|
136
184
|
[K in T]: any;
|
|
@@ -144,6 +192,7 @@ export declare class Request extends Macroable {
|
|
|
144
192
|
* ```js
|
|
145
193
|
* request.intended()
|
|
146
194
|
* ```
|
|
195
|
+
* @returns {string} Original HTTP method from the request
|
|
147
196
|
*/
|
|
148
197
|
intended(): string;
|
|
149
198
|
/**
|
|
@@ -159,15 +208,20 @@ export declare class Request extends Macroable {
|
|
|
159
208
|
* ```js
|
|
160
209
|
* request.method()
|
|
161
210
|
* ```
|
|
211
|
+
* @returns {string} HTTP method (potentially spoofed)
|
|
162
212
|
*/
|
|
163
213
|
method(): string;
|
|
164
214
|
/**
|
|
165
215
|
* Returns a copy of headers as an object
|
|
216
|
+
* @returns {IncomingHttpHeaders} Object containing all HTTP headers
|
|
166
217
|
*/
|
|
167
218
|
headers(): IncomingHttpHeaders;
|
|
168
219
|
/**
|
|
169
220
|
* Returns value for a given header key. The default value is
|
|
170
221
|
* used when original value is `undefined`.
|
|
222
|
+
* @param key - Header name to lookup
|
|
223
|
+
* @param defaultValue - Default value when header is not found
|
|
224
|
+
* @returns {string | undefined} Header value or default value if not found
|
|
171
225
|
*/
|
|
172
226
|
header(key: string, defaultValue?: any): string | undefined;
|
|
173
227
|
/**
|
|
@@ -200,6 +254,7 @@ export declare class Request extends Macroable {
|
|
|
200
254
|
* ```
|
|
201
255
|
*
|
|
202
256
|
* The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
|
|
257
|
+
* @returns {string} Client IP address
|
|
203
258
|
*/
|
|
204
259
|
ip(): string;
|
|
205
260
|
/**
|
|
@@ -219,6 +274,7 @@ export declare class Request extends Macroable {
|
|
|
219
274
|
* ```
|
|
220
275
|
*
|
|
221
276
|
* The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
|
|
277
|
+
* @returns {string[]} Array of IP addresses from most to least trusted
|
|
222
278
|
*/
|
|
223
279
|
ips(): string[];
|
|
224
280
|
/**
|
|
@@ -240,12 +296,14 @@ export declare class Request extends Macroable {
|
|
|
240
296
|
* ```
|
|
241
297
|
*
|
|
242
298
|
* The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
|
|
299
|
+
* @returns {string} Request protocol ('http' or 'https')
|
|
243
300
|
*/
|
|
244
301
|
protocol(): string;
|
|
245
302
|
/**
|
|
246
303
|
* Returns a boolean telling if request is served over `https`
|
|
247
304
|
* or not. Check [[protocol]] method to know how protocol is
|
|
248
305
|
* fetched.
|
|
306
|
+
* @returns {boolean} True if request is served over HTTPS
|
|
249
307
|
*/
|
|
250
308
|
secure(): boolean;
|
|
251
309
|
/**
|
|
@@ -264,6 +322,7 @@ export declare class Request extends Macroable {
|
|
|
264
322
|
* ```
|
|
265
323
|
*
|
|
266
324
|
* The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
|
|
325
|
+
* @returns {string | null} Request host or null if not found
|
|
267
326
|
*/
|
|
268
327
|
host(): string | null;
|
|
269
328
|
/**
|
|
@@ -282,6 +341,7 @@ export declare class Request extends Macroable {
|
|
|
282
341
|
* ```
|
|
283
342
|
*
|
|
284
343
|
* The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
|
|
344
|
+
* @returns {string | null} Request hostname (without port) or null if not found
|
|
285
345
|
*/
|
|
286
346
|
hostname(): string | null;
|
|
287
347
|
/**
|
|
@@ -289,16 +349,19 @@ export declare class Request extends Macroable {
|
|
|
289
349
|
* returned if [[hostname]] is `null` or is an IP address.
|
|
290
350
|
*
|
|
291
351
|
* Also `www` is not considered as a subdomain
|
|
352
|
+
* @returns {string[]} Array of subdomains (excluding www)
|
|
292
353
|
*/
|
|
293
354
|
subdomains(): string[];
|
|
294
355
|
/**
|
|
295
356
|
* Returns a boolean telling, if request `X-Requested-With === 'xmlhttprequest'`
|
|
296
357
|
* or not.
|
|
358
|
+
* @returns {boolean} True if request is an AJAX request
|
|
297
359
|
*/
|
|
298
360
|
ajax(): boolean;
|
|
299
361
|
/**
|
|
300
362
|
* Returns a boolean telling, if request has `X-Pjax` header
|
|
301
363
|
* set or not
|
|
364
|
+
* @returns {boolean} True if request is a PJAX request
|
|
302
365
|
*/
|
|
303
366
|
pjax(): boolean;
|
|
304
367
|
/**
|
|
@@ -311,6 +374,8 @@ export declare class Request extends Macroable {
|
|
|
311
374
|
* // include query string
|
|
312
375
|
* request.url(true)
|
|
313
376
|
* ```
|
|
377
|
+
* @param includeQueryString - Whether to include query string in the URL
|
|
378
|
+
* @returns {string} Request pathname, optionally with query string
|
|
314
379
|
*/
|
|
315
380
|
url(includeQueryString?: boolean): string;
|
|
316
381
|
/**
|
|
@@ -324,10 +389,14 @@ export declare class Request extends Macroable {
|
|
|
324
389
|
* // include query string
|
|
325
390
|
* request.completeUrl(true)
|
|
326
391
|
* ```
|
|
392
|
+
* @param includeQueryString - Whether to include query string in the URL
|
|
393
|
+
* @returns {string} Complete URL including protocol and host
|
|
327
394
|
*/
|
|
328
395
|
completeUrl(includeQueryString?: boolean): string;
|
|
329
396
|
/**
|
|
330
397
|
* Find if the current HTTP request is for the given route or the routes
|
|
398
|
+
* @param routeIdentifier - Route name, pattern, or handler reference to match
|
|
399
|
+
* @returns {boolean} True if the request matches any of the given route identifiers
|
|
331
400
|
*/
|
|
332
401
|
matchesRoute(routeIdentifier: string | string[]): boolean;
|
|
333
402
|
/**
|
|
@@ -357,6 +426,8 @@ export declare class Request extends Macroable {
|
|
|
357
426
|
* // process XML
|
|
358
427
|
* }
|
|
359
428
|
* ```
|
|
429
|
+
* @param types - Array of content types to match against
|
|
430
|
+
* @returns {string | null} Best matching content type or null if no match
|
|
360
431
|
*/
|
|
361
432
|
is(types: string[]): string | null;
|
|
362
433
|
/**
|
|
@@ -379,6 +450,8 @@ export declare class Request extends Macroable {
|
|
|
379
450
|
* // decide yourself
|
|
380
451
|
* }
|
|
381
452
|
* ```
|
|
453
|
+
* @param types - Array of types to match against Accept header
|
|
454
|
+
* @returns {T | null} Best matching accept type or null if no match
|
|
382
455
|
*/
|
|
383
456
|
accepts<T extends string>(types: T[]): T | null;
|
|
384
457
|
/**
|
|
@@ -387,6 +460,7 @@ export declare class Request extends Macroable {
|
|
|
387
460
|
*
|
|
388
461
|
* Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
|
|
389
462
|
* docs too.
|
|
463
|
+
* @returns {string[]} Array of accepted types in preference order
|
|
390
464
|
*/
|
|
391
465
|
types(): string[];
|
|
392
466
|
/**
|
|
@@ -409,6 +483,8 @@ export declare class Request extends Macroable {
|
|
|
409
483
|
* return view.render('about', { lang: 'en' })
|
|
410
484
|
* }
|
|
411
485
|
* ```
|
|
486
|
+
* @param languages - Array of languages to match against Accept-Language header
|
|
487
|
+
* @returns {T | null} Best matching language or null if no match
|
|
412
488
|
*/
|
|
413
489
|
language<T extends string>(languages: T[]): T | null;
|
|
414
490
|
/**
|
|
@@ -417,6 +493,7 @@ export declare class Request extends Macroable {
|
|
|
417
493
|
*
|
|
418
494
|
* Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
|
|
419
495
|
* docs too.
|
|
496
|
+
* @returns {string[]} Array of accepted languages in preference order
|
|
420
497
|
*/
|
|
421
498
|
languages(): string[];
|
|
422
499
|
/**
|
|
@@ -437,6 +514,8 @@ export declare class Request extends Macroable {
|
|
|
437
514
|
* // make ISO-8859-1 friendly response
|
|
438
515
|
* }
|
|
439
516
|
* ```
|
|
517
|
+
* @param charsets - Array of charsets to match against Accept-Charset header
|
|
518
|
+
* @returns {T | null} Best matching charset or null if no match
|
|
440
519
|
*/
|
|
441
520
|
charset<T extends string>(charsets: T[]): T | null;
|
|
442
521
|
/**
|
|
@@ -445,6 +524,7 @@ export declare class Request extends Macroable {
|
|
|
445
524
|
*
|
|
446
525
|
* Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
|
|
447
526
|
* docs too.
|
|
527
|
+
* @returns {string[]} Array of accepted charsets in preference order
|
|
448
528
|
*/
|
|
449
529
|
charsets(): string[];
|
|
450
530
|
/**
|
|
@@ -455,18 +535,22 @@ export declare class Request extends Macroable {
|
|
|
455
535
|
*
|
|
456
536
|
* Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
|
|
457
537
|
* docs too.
|
|
538
|
+
* @param encodings - Array of encodings to match against Accept-Encoding header
|
|
539
|
+
* @returns {T | null} Best matching encoding or null if no match
|
|
458
540
|
*/
|
|
459
541
|
encoding<T extends string>(encodings: T[]): T | null;
|
|
460
542
|
/**
|
|
461
|
-
* Return the
|
|
543
|
+
* Return the encodings that the request accepts, in the order of the
|
|
462
544
|
* client's preference (most preferred first).
|
|
463
545
|
*
|
|
464
546
|
* Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
|
|
465
547
|
* docs too.
|
|
548
|
+
* @returns {string[]} Array of accepted encodings in preference order
|
|
466
549
|
*/
|
|
467
550
|
encodings(): string[];
|
|
468
551
|
/**
|
|
469
552
|
* Returns a boolean telling if request has body
|
|
553
|
+
* @returns {boolean} True if request contains a body
|
|
470
554
|
*/
|
|
471
555
|
hasBody(): boolean;
|
|
472
556
|
/**
|
|
@@ -492,30 +576,44 @@ export declare class Request extends Macroable {
|
|
|
492
576
|
* response.send(responseBody)
|
|
493
577
|
* }
|
|
494
578
|
* ```
|
|
579
|
+
* @returns {boolean} True if client cache is fresh (should return 304)
|
|
495
580
|
*/
|
|
496
581
|
fresh(): boolean;
|
|
497
582
|
/**
|
|
498
583
|
* Opposite of [[fresh]]
|
|
584
|
+
* @returns {boolean} True if client cache is stale (should send new response)
|
|
499
585
|
*/
|
|
500
586
|
stale(): boolean;
|
|
501
587
|
/**
|
|
502
588
|
* Returns all parsed and signed cookies. Signed cookies ensures
|
|
503
589
|
* that their value isn't tampered.
|
|
590
|
+
* @returns {{ [key: string]: any }} Object containing all parsed cookies
|
|
504
591
|
*/
|
|
505
|
-
cookiesList():
|
|
592
|
+
cookiesList(): {
|
|
593
|
+
[key: string]: any;
|
|
594
|
+
};
|
|
506
595
|
/**
|
|
507
596
|
* Returns value for a given key from signed cookies. Optional
|
|
508
597
|
* defaultValue is returned when actual value is undefined.
|
|
598
|
+
* @param key - Cookie name to lookup
|
|
599
|
+
* @param defaultValue - Default value when cookie is not found
|
|
600
|
+
* @returns Cookie value or default value if not found
|
|
509
601
|
*/
|
|
510
602
|
cookie(key: string, defaultValue?: string): any;
|
|
511
603
|
/**
|
|
512
|
-
* Returns value for a given key from
|
|
604
|
+
* Returns value for a given key from encrypted cookies. Optional
|
|
513
605
|
* defaultValue is returned when actual value is undefined.
|
|
606
|
+
* @param key - Cookie name to lookup
|
|
607
|
+
* @param defaultValue - Default value when cookie is not found
|
|
608
|
+
* @returns Decrypted cookie value or default value if not found
|
|
514
609
|
*/
|
|
515
610
|
encryptedCookie(key: string, defaultValue?: string): any;
|
|
516
611
|
/**
|
|
517
612
|
* Returns value for a given key from unsigned cookies. Optional
|
|
518
613
|
* defaultValue is returned when actual value is undefined.
|
|
614
|
+
* @param key - Cookie name to lookup
|
|
615
|
+
* @param options - Options object with defaultValue and encoded flag
|
|
616
|
+
* @returns Plain cookie value or default value if not found
|
|
519
617
|
*/
|
|
520
618
|
plainCookie(key: string, options?: {
|
|
521
619
|
defaultValue?: string;
|
|
@@ -523,12 +621,15 @@ export declare class Request extends Macroable {
|
|
|
523
621
|
}): any;
|
|
524
622
|
plainCookie(key: string, defaultValue?: string, encoded?: boolean): any;
|
|
525
623
|
/**
|
|
526
|
-
* Returns a boolean telling if a signed url
|
|
624
|
+
* Returns a boolean telling if a signed url has a valid signature
|
|
527
625
|
* or not.
|
|
626
|
+
* @param purpose - Optional purpose for signature verification
|
|
627
|
+
* @returns {boolean} True if the signed URL has a valid signature
|
|
528
628
|
*/
|
|
529
629
|
hasValidSignature(purpose?: string): boolean;
|
|
530
630
|
/**
|
|
531
631
|
* Serializes request to JSON format
|
|
632
|
+
* @returns Object representation of the request
|
|
532
633
|
*/
|
|
533
634
|
serialize(): {
|
|
534
635
|
id: string | undefined;
|
|
@@ -539,13 +640,16 @@ export declare class Request extends Macroable {
|
|
|
539
640
|
headers: IncomingHttpHeaders;
|
|
540
641
|
method: string;
|
|
541
642
|
protocol: string;
|
|
542
|
-
cookies:
|
|
643
|
+
cookies: {
|
|
644
|
+
[key: string]: any;
|
|
645
|
+
};
|
|
543
646
|
hostname: string | null;
|
|
544
647
|
ip: string;
|
|
545
648
|
subdomains: Record<string, any>;
|
|
546
649
|
};
|
|
547
650
|
/**
|
|
548
651
|
* toJSON copy of the request
|
|
652
|
+
* @returns JSON representation of the request
|
|
549
653
|
*/
|
|
550
654
|
toJSON(): {
|
|
551
655
|
id: string | undefined;
|
|
@@ -556,7 +660,9 @@ export declare class Request extends Macroable {
|
|
|
556
660
|
headers: IncomingHttpHeaders;
|
|
557
661
|
method: string;
|
|
558
662
|
protocol: string;
|
|
559
|
-
cookies:
|
|
663
|
+
cookies: {
|
|
664
|
+
[key: string]: any;
|
|
665
|
+
};
|
|
560
666
|
hostname: string | null;
|
|
561
667
|
ip: string;
|
|
562
668
|
subdomains: Record<string, any>;
|