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