@adonisjs/http-server 6.8.2-8 → 7.0.0-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/build/chunk-XX72ATFY.js +4388 -0
- package/build/factories/main.d.ts +149 -6
- package/build/factories/main.js +331 -14
- package/build/index.d.ts +272 -14
- package/build/index.js +308 -22
- package/build/{src/server/main.d.ts → main-29eaaee4.d.ts} +12 -17
- package/build/main-e5b46c83.d.ts +2210 -0
- package/build/src/types/main.d.ts +14 -7
- package/build/src/types/main.js +0 -15
- package/package.json +65 -55
- package/build/factories/http_context.d.ts +0 -25
- package/build/factories/http_context.js +0 -51
- package/build/factories/http_server.d.ts +0 -8
- package/build/factories/http_server.js +0 -26
- package/build/factories/qs_parser_factory.d.ts +0 -20
- package/build/factories/qs_parser_factory.js +0 -44
- package/build/factories/request.d.ts +0 -29
- package/build/factories/request.js +0 -73
- package/build/factories/response.d.ts +0 -29
- package/build/factories/response.js +0 -77
- package/build/factories/router.d.ts +0 -23
- package/build/factories/router.js +0 -45
- package/build/factories/server_factory.d.ts +0 -29
- package/build/factories/server_factory.js +0 -65
- package/build/src/cookies/client.d.ts +0 -37
- package/build/src/cookies/client.js +0 -84
- package/build/src/cookies/drivers/encrypted.d.ts +0 -16
- package/build/src/cookies/drivers/encrypted.js +0 -36
- package/build/src/cookies/drivers/plain.d.ts +0 -15
- package/build/src/cookies/drivers/plain.js +0 -33
- package/build/src/cookies/drivers/signed.d.ts +0 -16
- package/build/src/cookies/drivers/signed.js +0 -36
- package/build/src/cookies/parser.d.ts +0 -37
- package/build/src/cookies/parser.js +0 -167
- package/build/src/cookies/serializer.d.ts +0 -33
- package/build/src/cookies/serializer.js +0 -79
- package/build/src/debug.d.ts +0 -3
- package/build/src/debug.js +0 -10
- package/build/src/define_config.d.ts +0 -5
- package/build/src/define_config.js +0 -51
- package/build/src/define_middleware.d.ts +0 -11
- package/build/src/define_middleware.js +0 -35
- package/build/src/exception_handler.d.ts +0 -90
- package/build/src/exception_handler.js +0 -239
- package/build/src/exceptions.d.ts +0 -84
- package/build/src/exceptions.js +0 -38
- package/build/src/helpers.d.ts +0 -23
- package/build/src/helpers.js +0 -84
- package/build/src/http_context/local_storage.d.ts +0 -12
- package/build/src/http_context/local_storage.js +0 -39
- package/build/src/http_context/main.d.ts +0 -58
- package/build/src/http_context/main.js +0 -105
- package/build/src/qs.d.ts +0 -11
- package/build/src/qs.js +0 -25
- package/build/src/redirect.d.ts +0 -42
- package/build/src/redirect.js +0 -140
- package/build/src/request.d.ts +0 -565
- package/build/src/request.js +0 -865
- package/build/src/response.d.ts +0 -540
- package/build/src/response.js +0 -1208
- package/build/src/router/brisk.d.ts +0 -42
- package/build/src/router/brisk.js +0 -85
- package/build/src/router/executor.d.ts +0 -8
- package/build/src/router/executor.js +0 -29
- package/build/src/router/factories/use_return_value.d.ts +0 -6
- package/build/src/router/factories/use_return_value.js +0 -22
- package/build/src/router/group.d.ts +0 -65
- package/build/src/router/group.js +0 -207
- package/build/src/router/lookup_store/main.d.ts +0 -49
- package/build/src/router/lookup_store/main.js +0 -86
- package/build/src/router/lookup_store/route_finder.d.ts +0 -21
- package/build/src/router/lookup_store/route_finder.js +0 -49
- package/build/src/router/lookup_store/url_builder.d.ts +0 -52
- package/build/src/router/lookup_store/url_builder.js +0 -209
- package/build/src/router/main.d.ts +0 -128
- package/build/src/router/main.js +0 -316
- package/build/src/router/matchers.d.ts +0 -27
- package/build/src/router/matchers.js +0 -36
- package/build/src/router/parser.d.ts +0 -5
- package/build/src/router/parser.js +0 -17
- package/build/src/router/resource.d.ts +0 -54
- package/build/src/router/resource.js +0 -216
- package/build/src/router/route.d.ts +0 -92
- package/build/src/router/route.js +0 -293
- package/build/src/router/store.d.ts +0 -66
- package/build/src/router/store.js +0 -195
- package/build/src/server/factories/final_handler.d.ts +0 -9
- package/build/src/server/factories/final_handler.js +0 -30
- package/build/src/server/factories/middleware_handler.d.ts +0 -8
- package/build/src/server/factories/middleware_handler.js +0 -16
- package/build/src/server/factories/write_response.d.ts +0 -6
- package/build/src/server/factories/write_response.js +0 -24
- package/build/src/server/main.js +0 -283
- package/build/src/types/base.d.ts +0 -19
- package/build/src/types/base.js +0 -9
- package/build/src/types/middleware.d.ts +0 -35
- package/build/src/types/middleware.js +0 -9
- package/build/src/types/qs.d.ts +0 -68
- package/build/src/types/qs.js +0 -9
- package/build/src/types/request.d.ts +0 -39
- package/build/src/types/request.js +0 -9
- package/build/src/types/response.d.ts +0 -45
- package/build/src/types/response.js +0 -9
- package/build/src/types/route.d.ts +0 -165
- package/build/src/types/route.js +0 -9
- package/build/src/types/server.d.ts +0 -72
- package/build/src/types/server.js +0 -9
package/build/src/request.d.ts
DELETED
|
@@ -1,565 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
import Macroable from '@poppinss/macroable';
|
|
4
|
-
import { UrlWithStringQuery } from 'node:url';
|
|
5
|
-
import type { Encryption } from '@adonisjs/encryption';
|
|
6
|
-
import { ServerResponse, IncomingMessage, IncomingHttpHeaders } from 'node:http';
|
|
7
|
-
import type { Qs } from './qs.js';
|
|
8
|
-
import { RequestConfig } from './types/request.js';
|
|
9
|
-
import type { HttpContext } from './http_context/main.js';
|
|
10
|
-
/**
|
|
11
|
-
* HTTP Request class exposes the interface to consistently read values
|
|
12
|
-
* related to a given HTTP request. The class is wrapper over
|
|
13
|
-
* [IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage)
|
|
14
|
-
* and has extended API.
|
|
15
|
-
*
|
|
16
|
-
* You can access the original [IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage)
|
|
17
|
-
* using `request.request` property.
|
|
18
|
-
*/
|
|
19
|
-
export declare class Request extends Macroable {
|
|
20
|
-
#private;
|
|
21
|
-
request: IncomingMessage;
|
|
22
|
-
response: ServerResponse;
|
|
23
|
-
/**
|
|
24
|
-
* Parses copy of the URL with query string as a string and not
|
|
25
|
-
* object. This is done to build URL's with query string without
|
|
26
|
-
* stringifying the object
|
|
27
|
-
*/
|
|
28
|
-
parsedUrl: UrlWithStringQuery;
|
|
29
|
-
/**
|
|
30
|
-
* The ctx will be set by the context itself. It creates a circular
|
|
31
|
-
* reference
|
|
32
|
-
*/
|
|
33
|
-
ctx?: HttpContext;
|
|
34
|
-
constructor(request: IncomingMessage, response: ServerResponse, encryption: Encryption, config: RequestConfig, qsParser: Qs);
|
|
35
|
-
/**
|
|
36
|
-
* Returns the request id from the `x-request-id` header. The
|
|
37
|
-
* header is untouched, if it already exists.
|
|
38
|
-
*/
|
|
39
|
-
id(): string | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* Set initial request body. A copy of the input will be maintained as the original
|
|
42
|
-
* request body. Since the request body and query string is subject to mutations, we
|
|
43
|
-
* keep one original reference to flash old data (whenever required).
|
|
44
|
-
*
|
|
45
|
-
* This method is supposed to be invoked by the body parser and must be called only
|
|
46
|
-
* once. For further mutations make use of `updateBody` method.
|
|
47
|
-
*/
|
|
48
|
-
setInitialBody(body: Record<string, any>): void;
|
|
49
|
-
/**
|
|
50
|
-
* Update the request body with new data object. The `all` property
|
|
51
|
-
* will be re-computed by merging the query string and request
|
|
52
|
-
* body.
|
|
53
|
-
*/
|
|
54
|
-
updateBody(body: Record<string, any>): void;
|
|
55
|
-
/**
|
|
56
|
-
* Update the request raw body. Bodyparser sets this when unable to parse
|
|
57
|
-
* the request body or when request is multipart/form-data.
|
|
58
|
-
*/
|
|
59
|
-
updateRawBody(rawBody: string): void;
|
|
60
|
-
/**
|
|
61
|
-
* Update the query string with the new data object. The `all` property
|
|
62
|
-
* will be re-computed by merging the query and the request body.
|
|
63
|
-
*/
|
|
64
|
-
updateQs(data: Record<string, any>): void;
|
|
65
|
-
/**
|
|
66
|
-
* Returns route params
|
|
67
|
-
*/
|
|
68
|
-
params(): Record<string, any>;
|
|
69
|
-
/**
|
|
70
|
-
* Returns the query string object by reference
|
|
71
|
-
*/
|
|
72
|
-
qs(): Record<string, any>;
|
|
73
|
-
/**
|
|
74
|
-
* Returns reference to the request body
|
|
75
|
-
*/
|
|
76
|
-
body(): Record<string, any>;
|
|
77
|
-
/**
|
|
78
|
-
* Returns reference to the merged copy of request body
|
|
79
|
-
* and query string
|
|
80
|
-
*/
|
|
81
|
-
all(): Record<string, any>;
|
|
82
|
-
/**
|
|
83
|
-
* Returns reference to the merged copy of original request
|
|
84
|
-
* query string and body
|
|
85
|
-
*/
|
|
86
|
-
original(): Record<string, any>;
|
|
87
|
-
/**
|
|
88
|
-
* Returns the request raw body (if exists), or returns `null`.
|
|
89
|
-
*
|
|
90
|
-
* Ideally you must be dealing with the parsed body accessed using [[input]], [[all]] or
|
|
91
|
-
* [[post]] methods. The `raw` body is always a string.
|
|
92
|
-
*/
|
|
93
|
-
raw(): string | null;
|
|
94
|
-
/**
|
|
95
|
-
* Returns value for a given key from the request body or query string.
|
|
96
|
-
* The `defaultValue` is used when original value is `undefined`.
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```js
|
|
100
|
-
* request.input('username')
|
|
101
|
-
*
|
|
102
|
-
* // with default value
|
|
103
|
-
* request.input('username', 'virk')
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
input(key: string, defaultValue?: any): any;
|
|
107
|
-
/**
|
|
108
|
-
* Returns value for a given key from route params
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* ```js
|
|
112
|
-
* request.param('id')
|
|
113
|
-
*
|
|
114
|
-
* // with default value
|
|
115
|
-
* request.param('id', 1)
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
param(key: string, defaultValue?: any): any;
|
|
119
|
-
/**
|
|
120
|
-
* Get everything from the request body except the given keys.
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* ```js
|
|
124
|
-
* request.except(['_csrf'])
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
except(keys: string[]): Record<string, any>;
|
|
128
|
-
/**
|
|
129
|
-
* Get value for specified keys.
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* ```js
|
|
133
|
-
* request.only(['username', 'age'])
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
only<T extends string>(keys: T[]): {
|
|
137
|
-
[K in T]: any;
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* Returns the HTTP request method. This is the original
|
|
141
|
-
* request method. For spoofed request method, make
|
|
142
|
-
* use of [[method]].
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* ```js
|
|
146
|
-
* request.intended()
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
intended(): string;
|
|
150
|
-
/**
|
|
151
|
-
* Returns the request HTTP method by taking method spoofing into account.
|
|
152
|
-
*
|
|
153
|
-
* Method spoofing works when all of the following are true.
|
|
154
|
-
*
|
|
155
|
-
* 1. `app.http.allowMethodSpoofing` config value is true.
|
|
156
|
-
* 2. request query string has `_method`.
|
|
157
|
-
* 3. The [[intended]] request method is `POST`.
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* ```js
|
|
161
|
-
* request.method()
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
method(): string;
|
|
165
|
-
/**
|
|
166
|
-
* Returns a copy of headers as an object
|
|
167
|
-
*/
|
|
168
|
-
headers(): IncomingHttpHeaders;
|
|
169
|
-
/**
|
|
170
|
-
* Returns value for a given header key. The default value is
|
|
171
|
-
* used when original value is `undefined`.
|
|
172
|
-
*/
|
|
173
|
-
header(key: string, defaultValue?: any): string | undefined;
|
|
174
|
-
/**
|
|
175
|
-
* Returns the ip address of the user. This method is optimize to fetch
|
|
176
|
-
* ip address even when running your AdonisJs app behind a proxy.
|
|
177
|
-
*
|
|
178
|
-
* You can also define your own custom function to compute the ip address by
|
|
179
|
-
* defining `app.http.getIp` as a function inside the config file.
|
|
180
|
-
*
|
|
181
|
-
* ```js
|
|
182
|
-
* {
|
|
183
|
-
* http: {
|
|
184
|
-
* getIp (request) {
|
|
185
|
-
* // I am using nginx as a proxy server and want to trust 'x-real-ip'
|
|
186
|
-
* return request.header('x-real-ip')
|
|
187
|
-
* }
|
|
188
|
-
* }
|
|
189
|
-
* }
|
|
190
|
-
* ```
|
|
191
|
-
*
|
|
192
|
-
* You can control the behavior of trusting the proxy values by defining it
|
|
193
|
-
* inside the `config/app.js` file.
|
|
194
|
-
*
|
|
195
|
-
* ```js
|
|
196
|
-
* {
|
|
197
|
-
* http: {
|
|
198
|
-
* trustProxy: '127.0.0.1'
|
|
199
|
-
* }
|
|
200
|
-
* }
|
|
201
|
-
* ```
|
|
202
|
-
*
|
|
203
|
-
* The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
|
|
204
|
-
*/
|
|
205
|
-
ip(): string;
|
|
206
|
-
/**
|
|
207
|
-
* Returns an array of ip addresses from most to least trusted one.
|
|
208
|
-
* This method is optimize to fetch ip address even when running
|
|
209
|
-
* your AdonisJs app behind a proxy.
|
|
210
|
-
*
|
|
211
|
-
* You can control the behavior of trusting the proxy values by defining it
|
|
212
|
-
* inside the `config/app.js` file.
|
|
213
|
-
*
|
|
214
|
-
* ```js
|
|
215
|
-
* {
|
|
216
|
-
* http: {
|
|
217
|
-
* trustProxy: '127.0.0.1'
|
|
218
|
-
* }
|
|
219
|
-
* }
|
|
220
|
-
* ```
|
|
221
|
-
*
|
|
222
|
-
* The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
|
|
223
|
-
*/
|
|
224
|
-
ips(): string[];
|
|
225
|
-
/**
|
|
226
|
-
* Returns the request protocol by checking for the URL protocol or
|
|
227
|
-
* `X-Forwarded-Proto` header.
|
|
228
|
-
*
|
|
229
|
-
* If the `trust` is evaluated to `false`, then URL protocol is returned,
|
|
230
|
-
* otherwise `X-Forwarded-Proto` header is used (if exists).
|
|
231
|
-
*
|
|
232
|
-
* You can control the behavior of trusting the proxy values by defining it
|
|
233
|
-
* inside the `config/app.js` file.
|
|
234
|
-
*
|
|
235
|
-
* ```js
|
|
236
|
-
* {
|
|
237
|
-
* http: {
|
|
238
|
-
* trustProxy: '127.0.0.1'
|
|
239
|
-
* }
|
|
240
|
-
* }
|
|
241
|
-
* ```
|
|
242
|
-
*
|
|
243
|
-
* The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
|
|
244
|
-
*/
|
|
245
|
-
protocol(): string;
|
|
246
|
-
/**
|
|
247
|
-
* Returns a boolean telling if request is served over `https`
|
|
248
|
-
* or not. Check [[protocol]] method to know how protocol is
|
|
249
|
-
* fetched.
|
|
250
|
-
*/
|
|
251
|
-
secure(): boolean;
|
|
252
|
-
/**
|
|
253
|
-
* Returns the request host. If proxy headers are trusted, then
|
|
254
|
-
* `X-Forwarded-Host` is given priority over the `Host` header.
|
|
255
|
-
*
|
|
256
|
-
* You can control the behavior of trusting the proxy values by defining it
|
|
257
|
-
* inside the `config/app.js` file.
|
|
258
|
-
*
|
|
259
|
-
* ```js
|
|
260
|
-
* {
|
|
261
|
-
* http: {
|
|
262
|
-
* trustProxy: '127.0.0.1'
|
|
263
|
-
* }
|
|
264
|
-
* }
|
|
265
|
-
* ```
|
|
266
|
-
*
|
|
267
|
-
* The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
|
|
268
|
-
*/
|
|
269
|
-
host(): string | null;
|
|
270
|
-
/**
|
|
271
|
-
* Returns the request hostname. If proxy headers are trusted, then
|
|
272
|
-
* `X-Forwarded-Host` is given priority over the `Host` header.
|
|
273
|
-
*
|
|
274
|
-
* You can control the behavior of trusting the proxy values by defining it
|
|
275
|
-
* inside the `config/app.js` file.
|
|
276
|
-
*
|
|
277
|
-
* ```js
|
|
278
|
-
* {
|
|
279
|
-
* http: {
|
|
280
|
-
* trustProxy: '127.0.0.1'
|
|
281
|
-
* }
|
|
282
|
-
* }
|
|
283
|
-
* ```
|
|
284
|
-
*
|
|
285
|
-
* The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
|
|
286
|
-
*/
|
|
287
|
-
hostname(): string | null;
|
|
288
|
-
/**
|
|
289
|
-
* Returns an array of subdomains for the given host. An empty array is
|
|
290
|
-
* returned if [[hostname]] is `null` or is an IP address.
|
|
291
|
-
*
|
|
292
|
-
* Also `www` is not considered as a subdomain
|
|
293
|
-
*/
|
|
294
|
-
subdomains(): string[];
|
|
295
|
-
/**
|
|
296
|
-
* Returns a boolean telling, if request `X-Requested-With === 'xmlhttprequest'`
|
|
297
|
-
* or not.
|
|
298
|
-
*/
|
|
299
|
-
ajax(): boolean;
|
|
300
|
-
/**
|
|
301
|
-
* Returns a boolean telling, if request has `X-Pjax` header
|
|
302
|
-
* set or not
|
|
303
|
-
*/
|
|
304
|
-
pjax(): boolean;
|
|
305
|
-
/**
|
|
306
|
-
* Returns the request relative URL.
|
|
307
|
-
*
|
|
308
|
-
* @example
|
|
309
|
-
* ```js
|
|
310
|
-
* request.url()
|
|
311
|
-
*
|
|
312
|
-
* // include query string
|
|
313
|
-
* request.url(true)
|
|
314
|
-
* ```
|
|
315
|
-
*/
|
|
316
|
-
url(includeQueryString?: boolean): string;
|
|
317
|
-
/**
|
|
318
|
-
* Returns the complete HTTP url by combining
|
|
319
|
-
* [[protocol]]://[[hostname]]/[[url]]
|
|
320
|
-
*
|
|
321
|
-
* @example
|
|
322
|
-
* ```js
|
|
323
|
-
* request.completeUrl()
|
|
324
|
-
*
|
|
325
|
-
* // include query string
|
|
326
|
-
* request.completeUrl(true)
|
|
327
|
-
* ```
|
|
328
|
-
*/
|
|
329
|
-
completeUrl(includeQueryString?: boolean): string;
|
|
330
|
-
/**
|
|
331
|
-
* Find if the current HTTP request is for the given route or the routes
|
|
332
|
-
*/
|
|
333
|
-
matchesRoute(routeIdentifier: string | string[]): boolean;
|
|
334
|
-
/**
|
|
335
|
-
* Returns the best matching content type of the request by
|
|
336
|
-
* matching against the given types.
|
|
337
|
-
*
|
|
338
|
-
* The content type is picked from the `content-type` header and request
|
|
339
|
-
* must have body.
|
|
340
|
-
*
|
|
341
|
-
* The method response highly depends upon the types array values. Described below:
|
|
342
|
-
*
|
|
343
|
-
* | Type(s) | Return value |
|
|
344
|
-
* |----------|---------------|
|
|
345
|
-
* | ['json'] | json |
|
|
346
|
-
* | ['application/*'] | application/json |
|
|
347
|
-
* | ['vnd+json'] | application/json |
|
|
348
|
-
*
|
|
349
|
-
* @example
|
|
350
|
-
* ```js
|
|
351
|
-
* const bodyType = request.is(['json', 'xml'])
|
|
352
|
-
*
|
|
353
|
-
* if (bodyType === 'json') {
|
|
354
|
-
* // process JSON
|
|
355
|
-
* }
|
|
356
|
-
*
|
|
357
|
-
* if (bodyType === 'xml') {
|
|
358
|
-
* // process XML
|
|
359
|
-
* }
|
|
360
|
-
* ```
|
|
361
|
-
*/
|
|
362
|
-
is(types: string[]): string | null;
|
|
363
|
-
/**
|
|
364
|
-
* Returns the best type using `Accept` header and
|
|
365
|
-
* by matching it against the given types.
|
|
366
|
-
*
|
|
367
|
-
* If nothing is matched, then `null` will be returned
|
|
368
|
-
*
|
|
369
|
-
* Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
|
|
370
|
-
* docs too.
|
|
371
|
-
*
|
|
372
|
-
* @example
|
|
373
|
-
* ```js
|
|
374
|
-
* switch (request.accepts(['json', 'html'])) {
|
|
375
|
-
* case 'json':
|
|
376
|
-
* return response.json(user)
|
|
377
|
-
* case 'html':
|
|
378
|
-
* return view.render('user', { user })
|
|
379
|
-
* default:
|
|
380
|
-
* // decide yourself
|
|
381
|
-
* }
|
|
382
|
-
* ```
|
|
383
|
-
*/
|
|
384
|
-
accepts<T extends string>(types: T[]): T | null;
|
|
385
|
-
/**
|
|
386
|
-
* Return the types that the request accepts, in the order of the
|
|
387
|
-
* client's preference (most preferred first).
|
|
388
|
-
*
|
|
389
|
-
* Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
|
|
390
|
-
* docs too.
|
|
391
|
-
*/
|
|
392
|
-
types(): string[];
|
|
393
|
-
/**
|
|
394
|
-
* Returns the best language using `Accept-language` header
|
|
395
|
-
* and by matching it against the given languages.
|
|
396
|
-
*
|
|
397
|
-
* If nothing is matched, then `null` will be returned
|
|
398
|
-
*
|
|
399
|
-
* Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
|
|
400
|
-
* docs too.
|
|
401
|
-
*
|
|
402
|
-
* @example
|
|
403
|
-
* ```js
|
|
404
|
-
* switch (request.language(['fr', 'de'])) {
|
|
405
|
-
* case 'fr':
|
|
406
|
-
* return view.render('about', { lang: 'fr' })
|
|
407
|
-
* case 'de':
|
|
408
|
-
* return view.render('about', { lang: 'de' })
|
|
409
|
-
* default:
|
|
410
|
-
* return view.render('about', { lang: 'en' })
|
|
411
|
-
* }
|
|
412
|
-
* ```
|
|
413
|
-
*/
|
|
414
|
-
language<T extends string>(languages: T[]): T | null;
|
|
415
|
-
/**
|
|
416
|
-
* Return the languages that the request accepts, in the order of the
|
|
417
|
-
* client's preference (most preferred first).
|
|
418
|
-
*
|
|
419
|
-
* Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
|
|
420
|
-
* docs too.
|
|
421
|
-
*/
|
|
422
|
-
languages(): string[];
|
|
423
|
-
/**
|
|
424
|
-
* Returns the best charset using `Accept-charset` header
|
|
425
|
-
* and by matching it against the given charsets.
|
|
426
|
-
*
|
|
427
|
-
* If nothing is matched, then `null` will be returned
|
|
428
|
-
*
|
|
429
|
-
* Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
|
|
430
|
-
* docs too.
|
|
431
|
-
*
|
|
432
|
-
* @example
|
|
433
|
-
* ```js
|
|
434
|
-
* switch (request.charset(['utf-8', 'ISO-8859-1'])) {
|
|
435
|
-
* case 'utf-8':
|
|
436
|
-
* // make utf-8 friendly response
|
|
437
|
-
* case 'ISO-8859-1':
|
|
438
|
-
* // make ISO-8859-1 friendly response
|
|
439
|
-
* }
|
|
440
|
-
* ```
|
|
441
|
-
*/
|
|
442
|
-
charset<T extends string>(charsets: T[]): T | null;
|
|
443
|
-
/**
|
|
444
|
-
* Return the charsets that the request accepts, in the order of the
|
|
445
|
-
* client's preference (most preferred first).
|
|
446
|
-
*
|
|
447
|
-
* Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
|
|
448
|
-
* docs too.
|
|
449
|
-
*/
|
|
450
|
-
charsets(): string[];
|
|
451
|
-
/**
|
|
452
|
-
* Returns the best encoding using `Accept-encoding` header
|
|
453
|
-
* and by matching it against the given encodings.
|
|
454
|
-
*
|
|
455
|
-
* If nothing is matched, then `null` will be returned
|
|
456
|
-
*
|
|
457
|
-
* Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
|
|
458
|
-
* docs too.
|
|
459
|
-
*/
|
|
460
|
-
encoding<T extends string>(encodings: T[]): T | null;
|
|
461
|
-
/**
|
|
462
|
-
* Return the charsets that the request accepts, in the order of the
|
|
463
|
-
* client's preference (most preferred first).
|
|
464
|
-
*
|
|
465
|
-
* Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
|
|
466
|
-
* docs too.
|
|
467
|
-
*/
|
|
468
|
-
encodings(): string[];
|
|
469
|
-
/**
|
|
470
|
-
* Returns a boolean telling if request has body
|
|
471
|
-
*/
|
|
472
|
-
hasBody(): boolean;
|
|
473
|
-
/**
|
|
474
|
-
* Returns a boolean telling if the new response etag evaluates same
|
|
475
|
-
* as the request header `if-none-match`. In case of `true`, the
|
|
476
|
-
* server must return `304` response, telling the browser to
|
|
477
|
-
* use the client cache.
|
|
478
|
-
*
|
|
479
|
-
* You won't have to deal with this method directly, since AdonisJs will
|
|
480
|
-
* handle this for you when `http.etag = true` inside `config/app.js` file.
|
|
481
|
-
*
|
|
482
|
-
* However, this is how you can use it manually.
|
|
483
|
-
*
|
|
484
|
-
* ```js
|
|
485
|
-
* const responseBody = view.render('some-view')
|
|
486
|
-
*
|
|
487
|
-
* // sets the HTTP etag header for response
|
|
488
|
-
* response.setEtag(responseBody)
|
|
489
|
-
*
|
|
490
|
-
* if (request.fresh()) {
|
|
491
|
-
* response.sendStatus(304)
|
|
492
|
-
* } else {
|
|
493
|
-
* response.send(responseBody)
|
|
494
|
-
* }
|
|
495
|
-
* ```
|
|
496
|
-
*/
|
|
497
|
-
fresh(): boolean;
|
|
498
|
-
/**
|
|
499
|
-
* Opposite of [[fresh]]
|
|
500
|
-
*/
|
|
501
|
-
stale(): boolean;
|
|
502
|
-
/**
|
|
503
|
-
* Returns all parsed and signed cookies. Signed cookies ensures
|
|
504
|
-
* that their value isn't tampered.
|
|
505
|
-
*/
|
|
506
|
-
cookiesList(): Record<string, any>;
|
|
507
|
-
/**
|
|
508
|
-
* Returns value for a given key from signed cookies. Optional
|
|
509
|
-
* defaultValue is returned when actual value is undefined.
|
|
510
|
-
*/
|
|
511
|
-
cookie(key: string, defaultValue?: string): any;
|
|
512
|
-
/**
|
|
513
|
-
* Returns value for a given key from signed cookies. Optional
|
|
514
|
-
* defaultValue is returned when actual value is undefined.
|
|
515
|
-
*/
|
|
516
|
-
encryptedCookie(key: string, defaultValue?: string): any;
|
|
517
|
-
/**
|
|
518
|
-
* Returns value for a given key from unsigned cookies. Optional
|
|
519
|
-
* defaultValue is returned when actual value is undefined.
|
|
520
|
-
*/
|
|
521
|
-
plainCookie(key: string, options?: {
|
|
522
|
-
defaultValue?: string;
|
|
523
|
-
encoded?: boolean;
|
|
524
|
-
}): any;
|
|
525
|
-
plainCookie(key: string, defaultValue?: string, encoded?: boolean): any;
|
|
526
|
-
/**
|
|
527
|
-
* Returns a boolean telling if a signed url as a valid signature
|
|
528
|
-
* or not.
|
|
529
|
-
*/
|
|
530
|
-
hasValidSignature(purpose?: string): boolean;
|
|
531
|
-
/**
|
|
532
|
-
* Serializes request to JSON format
|
|
533
|
-
*/
|
|
534
|
-
serialize(): {
|
|
535
|
-
id: string | undefined;
|
|
536
|
-
url: string;
|
|
537
|
-
query: string | null;
|
|
538
|
-
body: Record<string, any>;
|
|
539
|
-
params: Record<string, any>;
|
|
540
|
-
headers: IncomingHttpHeaders;
|
|
541
|
-
method: string;
|
|
542
|
-
protocol: string;
|
|
543
|
-
cookies: Record<string, any>;
|
|
544
|
-
hostname: string | null;
|
|
545
|
-
ip: string;
|
|
546
|
-
subdomains: Record<string, any>;
|
|
547
|
-
};
|
|
548
|
-
/**
|
|
549
|
-
* toJSON copy of the request
|
|
550
|
-
*/
|
|
551
|
-
toJSON(): {
|
|
552
|
-
id: string | undefined;
|
|
553
|
-
url: string;
|
|
554
|
-
query: string | null;
|
|
555
|
-
body: Record<string, any>;
|
|
556
|
-
params: Record<string, any>;
|
|
557
|
-
headers: IncomingHttpHeaders;
|
|
558
|
-
method: string;
|
|
559
|
-
protocol: string;
|
|
560
|
-
cookies: Record<string, any>;
|
|
561
|
-
hostname: string | null;
|
|
562
|
-
ip: string;
|
|
563
|
-
subdomains: Record<string, any>;
|
|
564
|
-
};
|
|
565
|
-
}
|