@adonisjs/http-server 7.0.0-0 → 7.0.0-2

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 (62) hide show
  1. package/build/{chunk-XX72ATFY.js → chunk-Z63E3STR.js} +66 -18
  2. package/build/chunk-Z63E3STR.js.map +1 -0
  3. package/build/factories/http_context.d.ts +25 -0
  4. package/build/factories/http_server.d.ts +8 -0
  5. package/build/factories/main.d.ts +6 -149
  6. package/build/factories/main.js +2 -1
  7. package/build/factories/main.js.map +1 -0
  8. package/build/factories/qs_parser_factory.d.ts +20 -0
  9. package/build/factories/request.d.ts +29 -0
  10. package/build/factories/response.d.ts +29 -0
  11. package/build/factories/router.d.ts +23 -0
  12. package/build/factories/server_factory.d.ts +29 -0
  13. package/build/index.d.ts +14 -272
  14. package/build/index.js +2 -1
  15. package/build/index.js.map +1 -0
  16. package/build/src/cookies/client.d.ts +37 -0
  17. package/build/src/cookies/drivers/encrypted.d.ts +16 -0
  18. package/build/src/cookies/drivers/plain.d.ts +15 -0
  19. package/build/src/cookies/drivers/signed.d.ts +16 -0
  20. package/build/src/cookies/parser.d.ts +37 -0
  21. package/build/src/cookies/serializer.d.ts +33 -0
  22. package/build/src/debug.d.ts +3 -0
  23. package/build/src/define_config.d.ts +9 -0
  24. package/build/src/define_middleware.d.ts +11 -0
  25. package/build/src/exception_handler.d.ts +113 -0
  26. package/build/src/exceptions.d.ts +84 -0
  27. package/build/src/helpers.d.ts +23 -0
  28. package/build/src/http_context/local_storage.d.ts +12 -0
  29. package/build/src/http_context/main.d.ts +58 -0
  30. package/build/src/qs.d.ts +11 -0
  31. package/build/src/redirect.d.ts +42 -0
  32. package/build/src/request.d.ts +565 -0
  33. package/build/src/response.d.ts +620 -0
  34. package/build/src/router/brisk.d.ts +42 -0
  35. package/build/src/router/executor.d.ts +9 -0
  36. package/build/src/router/factories/use_return_value.d.ts +6 -0
  37. package/build/src/router/group.d.ts +65 -0
  38. package/build/src/router/lookup_store/main.d.ts +47 -0
  39. package/build/src/router/lookup_store/route_finder.d.ts +25 -0
  40. package/build/src/router/lookup_store/url_builder.d.ts +52 -0
  41. package/build/src/router/main.d.ts +128 -0
  42. package/build/src/router/matchers.d.ts +27 -0
  43. package/build/src/router/parser.d.ts +5 -0
  44. package/build/src/router/resource.d.ts +66 -0
  45. package/build/src/router/route.d.ts +92 -0
  46. package/build/src/router/store.d.ts +66 -0
  47. package/build/src/server/factories/final_handler.d.ts +10 -0
  48. package/build/src/server/factories/middleware_handler.d.ts +8 -0
  49. package/build/src/server/factories/write_response.d.ts +6 -0
  50. package/build/{main-29eaaee4.d.ts → src/server/main.d.ts} +18 -13
  51. package/build/src/types/base.d.ts +19 -0
  52. package/build/src/types/main.d.ts +7 -14
  53. package/build/src/types/main.js +1 -0
  54. package/build/src/types/main.js.map +1 -0
  55. package/build/src/types/middleware.d.ts +35 -0
  56. package/build/src/types/qs.d.ts +68 -0
  57. package/build/src/types/request.d.ts +39 -0
  58. package/build/src/types/response.d.ts +45 -0
  59. package/build/src/types/route.d.ts +166 -0
  60. package/build/src/types/server.d.ts +72 -0
  61. package/package.json +52 -48
  62. package/build/main-e5b46c83.d.ts +0 -2210
@@ -0,0 +1,620 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ /// <reference types="node" resolution-mode="require"/>
4
+ import Macroable from '@poppinss/macroable';
5
+ import type { Encryption } from '@adonisjs/encryption';
6
+ import { ServerResponse, IncomingMessage } from 'node:http';
7
+ import type { Qs } from './qs.js';
8
+ import { Redirect } from './redirect.js';
9
+ import type { Router } from './router/main.js';
10
+ import type { HttpContext } from './http_context/main.js';
11
+ import type { CastableHeader, CookieOptions, ResponseConfig, ResponseStream } from './types/response.js';
12
+ /**
13
+ * The response is a wrapper over [ServerResponse](https://nodejs.org/api/http.html#http_class_http_serverresponse)
14
+ * streamlining the process of writing response body and automatically setting up appropriate headers.
15
+ */
16
+ export declare class Response extends Macroable {
17
+ #private;
18
+ request: IncomingMessage;
19
+ response: ServerResponse;
20
+ /**
21
+ * Does response has body set that will written to the
22
+ * response socket at the end of the request
23
+ */
24
+ get hasLazyBody(): boolean;
25
+ /**
26
+ * Find if the response has non-stream content
27
+ */
28
+ get hasContent(): boolean;
29
+ /**
30
+ * Returns true when response body is set using "response.stream"
31
+ * method
32
+ */
33
+ get hasStream(): boolean;
34
+ /**
35
+ * Returns true when response body is set using "response.download"
36
+ * or "response.attachment" methods
37
+ */
38
+ get hasFileToStream(): boolean;
39
+ /**
40
+ * Returns the response content. Check if the response
41
+ * has content using the "hasContent" method
42
+ */
43
+ get content(): [any, boolean, (string | undefined)?] | undefined;
44
+ /**
45
+ * Returns reference to the stream set using "response.stream"
46
+ * method
47
+ */
48
+ get outgoingStream(): import("stream").Readable | undefined;
49
+ /**
50
+ * Returns reference to the file path set using "response.stream"
51
+ * method.
52
+ */
53
+ get fileToStream(): {
54
+ path: string;
55
+ generateEtag: boolean;
56
+ } | undefined;
57
+ /**
58
+ * Lazy body is used to set the response body. However, do not
59
+ * write it on the socket immediately unless `response.finish`
60
+ * is called.
61
+ */
62
+ lazyBody: Partial<{
63
+ content: [any, boolean, string?];
64
+ stream: [ResponseStream, ((error: NodeJS.ErrnoException) => [string, number?])?];
65
+ fileToStream: [string, boolean, ((error: NodeJS.ErrnoException) => [string, number?])?];
66
+ }>;
67
+ /**
68
+ * The ctx will be set by the context itself. It creates a circular
69
+ * reference
70
+ */
71
+ ctx?: HttpContext;
72
+ constructor(request: IncomingMessage, response: ServerResponse, encryption: Encryption, config: ResponseConfig, router: Router, qs: Qs);
73
+ /**
74
+ * Returns a boolean telling if response is finished or not.
75
+ * Any more attempts to update headers or body will result
76
+ * in raised exceptions.
77
+ */
78
+ get finished(): boolean;
79
+ /**
80
+ * Returns a boolean telling if response headers has been sent or not.
81
+ * Any more attempts to update headers will result in raised
82
+ * exceptions.
83
+ */
84
+ get headersSent(): boolean;
85
+ /**
86
+ * Returns a boolean telling if response headers and body is written
87
+ * or not. When value is `true`, you can feel free to write headers
88
+ * and body.
89
+ */
90
+ get isPending(): boolean;
91
+ /**
92
+ * Writes the body with appropriate response headers. Etag header is set
93
+ * when `generateEtag` is set to `true`.
94
+ *
95
+ * Empty body results in `204`.
96
+ */
97
+ protected writeBody(content: any, generateEtag: boolean, jsonpCallbackName?: string): void;
98
+ /**
99
+ * Stream the body to the response and handles cleaning up the stream
100
+ */
101
+ protected streamBody(body: ResponseStream, errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]): Promise<void>;
102
+ /**
103
+ * Downloads a file by streaming it to the response
104
+ */
105
+ protected streamFileForDownload(filePath: string, generateEtag: boolean, errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]): Promise<void>;
106
+ /**
107
+ * Writes headers with the Node.js res object using the
108
+ * response.setHeader method
109
+ */
110
+ relayHeaders(): void;
111
+ /**
112
+ * Calls res.writeHead on the Node.js res object.
113
+ */
114
+ writeHead(statusCode?: number): this;
115
+ /**
116
+ * Returns the existing value for a given HTTP response
117
+ * header.
118
+ */
119
+ getHeader(key: string): import("http").OutgoingHttpHeader | undefined;
120
+ /**
121
+ * Get response headers
122
+ */
123
+ getHeaders(): {
124
+ [x: string]: import("http").OutgoingHttpHeader | undefined;
125
+ accept?: string | string[] | undefined;
126
+ "accept-charset"?: string | string[] | undefined;
127
+ "accept-encoding"?: string | string[] | undefined;
128
+ "accept-language"?: string | string[] | undefined;
129
+ "accept-ranges"?: string | undefined;
130
+ "access-control-allow-credentials"?: string | undefined;
131
+ "access-control-allow-headers"?: string | undefined;
132
+ "access-control-allow-methods"?: string | undefined;
133
+ "access-control-allow-origin"?: string | undefined;
134
+ "access-control-expose-headers"?: string | undefined;
135
+ "access-control-max-age"?: string | undefined;
136
+ "access-control-request-headers"?: string | undefined;
137
+ "access-control-request-method"?: string | undefined;
138
+ age?: string | undefined;
139
+ allow?: string | undefined;
140
+ authorization?: string | undefined;
141
+ "cache-control"?: string | undefined;
142
+ "cdn-cache-control"?: string | undefined;
143
+ connection?: string | string[] | undefined;
144
+ "content-disposition"?: string | undefined;
145
+ "content-encoding"?: string | undefined;
146
+ "content-language"?: string | undefined;
147
+ "content-length"?: string | number | undefined;
148
+ "content-location"?: string | undefined;
149
+ "content-range"?: string | undefined;
150
+ "content-security-policy"?: string | undefined;
151
+ "content-security-policy-report-only"?: string | undefined;
152
+ cookie?: string | string[] | undefined;
153
+ dav?: string | string[] | undefined;
154
+ dnt?: string | undefined;
155
+ date?: string | undefined;
156
+ etag?: string | undefined;
157
+ expect?: string | undefined;
158
+ expires?: string | undefined;
159
+ forwarded?: string | undefined;
160
+ from?: string | undefined;
161
+ host?: string | undefined;
162
+ "if-match"?: string | undefined;
163
+ "if-modified-since"?: string | undefined;
164
+ "if-none-match"?: string | undefined;
165
+ "if-range"?: string | undefined;
166
+ "if-unmodified-since"?: string | undefined;
167
+ "last-modified"?: string | undefined;
168
+ link?: string | string[] | undefined;
169
+ location?: string | undefined;
170
+ "max-forwards"?: string | undefined;
171
+ origin?: string | undefined;
172
+ prgama?: string | string[] | undefined;
173
+ "proxy-authenticate"?: string | string[] | undefined;
174
+ "proxy-authorization"?: string | undefined;
175
+ "public-key-pins"?: string | undefined;
176
+ "public-key-pins-report-only"?: string | undefined;
177
+ range?: string | undefined;
178
+ referer?: string | undefined;
179
+ "referrer-policy"?: string | undefined;
180
+ refresh?: string | undefined;
181
+ "retry-after"?: string | undefined;
182
+ "sec-websocket-accept"?: string | undefined;
183
+ "sec-websocket-extensions"?: string | string[] | undefined;
184
+ "sec-websocket-key"?: string | undefined;
185
+ "sec-websocket-protocol"?: string | string[] | undefined;
186
+ "sec-websocket-version"?: string | undefined;
187
+ server?: string | undefined;
188
+ "set-cookie"?: string | string[] | undefined;
189
+ "strict-transport-security"?: string | undefined;
190
+ te?: string | undefined;
191
+ trailer?: string | undefined;
192
+ "transfer-encoding"?: string | undefined;
193
+ "user-agent"?: string | undefined;
194
+ upgrade?: string | undefined;
195
+ "upgrade-insecure-requests"?: string | undefined;
196
+ vary?: string | undefined;
197
+ via?: string | string[] | undefined;
198
+ warning?: string | undefined;
199
+ "www-authenticate"?: string | string[] | undefined;
200
+ "x-content-type-options"?: string | undefined;
201
+ "x-dns-prefetch-control"?: string | undefined;
202
+ "x-frame-options"?: string | undefined;
203
+ "x-xss-protection"?: string | undefined;
204
+ };
205
+ /**
206
+ * Set header on the response. To `append` values to the existing header, we suggest
207
+ * using [[append]] method.
208
+ *
209
+ * If `value` is non existy, then header won't be set.
210
+ *
211
+ * @example
212
+ * ```js
213
+ * response.header('content-type', 'application/json')
214
+ * ```
215
+ */
216
+ header(key: string, value: CastableHeader): this;
217
+ /**
218
+ * Append value to an existing header. To replace the value, we suggest using
219
+ * [[header]] method.
220
+ *
221
+ * If `value` is not existy, then header won't be set.
222
+ *
223
+ * @example
224
+ * ```js
225
+ * response.append('set-cookie', 'username=virk')
226
+ * ```
227
+ */
228
+ append(key: string, value: CastableHeader): this;
229
+ /**
230
+ * Adds HTTP response header, when it doesn't exists already.
231
+ */
232
+ safeHeader(key: string, value: CastableHeader): this;
233
+ /**
234
+ * Removes the existing response header from being sent.
235
+ */
236
+ removeHeader(key: string): this;
237
+ /**
238
+ * Returns the status code for the response
239
+ */
240
+ getStatus(): number;
241
+ /**
242
+ * Set HTTP status code
243
+ */
244
+ status(code: number): this;
245
+ /**
246
+ * Set's status code only when it's not explictly
247
+ * set
248
+ */
249
+ safeStatus(code: number): this;
250
+ /**
251
+ * Set response type by looking up for the mime-type using
252
+ * partial types like file extensions.
253
+ *
254
+ * Make sure to read [mime-types](https://www.npmjs.com/package/mime-types) docs
255
+ * too.
256
+ *
257
+ * @example
258
+ * ```js
259
+ * response.type('.json') // Content-type: application/json
260
+ * ```
261
+ */
262
+ type(type: string, charset?: string): this;
263
+ /**
264
+ * Set the Vary HTTP header
265
+ */
266
+ vary(field: string | string[]): this;
267
+ /**
268
+ * Set etag by computing hash from the body. This class will set the etag automatically
269
+ * when `etag = true` in the defined config object.
270
+ *
271
+ * Use this function, when you want to compute etag manually for some other resons.
272
+ */
273
+ setEtag(body: any, weak?: boolean): this;
274
+ /**
275
+ * Returns a boolean telling if the new response etag evaluates same
276
+ * as the request header `if-none-match`. In case of `true`, the
277
+ * server must return `304` response, telling the browser to
278
+ * use the client cache.
279
+ *
280
+ * You won't have to deal with this method directly, since AdonisJs will
281
+ * handle this for you when `http.etag = true` inside `config/app.js` file.
282
+ *
283
+ * However, this is how you can use it manually.
284
+ *
285
+ * @example
286
+ * ```js
287
+ * const responseBody = view.render('some-view')
288
+ *
289
+ * // sets the HTTP etag header for response
290
+ * response.setEtag(responseBody)
291
+ *
292
+ * if (response.fresh()) {
293
+ * response.sendStatus(304)
294
+ * } else {
295
+ * response.send(responseBody)
296
+ * }
297
+ * ```
298
+ */
299
+ fresh(): boolean;
300
+ /**
301
+ * Returns the response body. Returns null when response
302
+ * body is a stream
303
+ */
304
+ getBody(): any;
305
+ /**
306
+ * Send the body as response and optionally generate etag. The default value
307
+ * is read from `config/app.js` file, using `http.etag` property.
308
+ *
309
+ * This method buffers the body if `explicitEnd = true`, which is the default
310
+ * behavior and do not change, unless you know what you are doing.
311
+ */
312
+ send(body: any, generateEtag?: boolean): void;
313
+ /**
314
+ * Alias of [[send]]
315
+ */
316
+ json(body: any, generateEtag?: boolean): void;
317
+ /**
318
+ * Writes response as JSONP. The callback name is resolved as follows, with priority
319
+ * from top to bottom.
320
+ *
321
+ * 1. Explicitly defined as 2nd Param.
322
+ * 2. Fetch from request query string.
323
+ * 3. Use the config value `http.jsonpCallbackName` from `config/app.js`.
324
+ * 4. Fallback to `callback`.
325
+ *
326
+ * This method buffers the body if `explicitEnd = true`, which is the default
327
+ * behavior and do not change, unless you know what you are doing.
328
+ */
329
+ jsonp(body: any, callbackName?: string, generateEtag?: boolean): void;
330
+ /**
331
+ * Pipe stream to the response. This method will gracefully destroy
332
+ * the stream, avoiding memory leaks.
333
+ *
334
+ * If `raiseErrors=false`, then this method will self handle all the exceptions by
335
+ * writing a generic HTTP response. To have more control over the error, it is
336
+ * recommended to set `raiseErrors=true` and wrap this function inside a
337
+ * `try/catch` statement.
338
+ *
339
+ * Streaming a file from the disk and showing 404 when file is missing.
340
+ *
341
+ * @example
342
+ * ```js
343
+ * // Errors handled automatically with generic HTTP response
344
+ * response.stream(fs.createReadStream('file.txt'))
345
+ *
346
+ * // Manually handle (note the await call)
347
+ * try {
348
+ * await response.stream(fs.createReadStream('file.txt'))
349
+ * } catch () {
350
+ * response.status(404).send('File not found')
351
+ * }
352
+ * ```
353
+ */
354
+ stream(body: ResponseStream, errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]): void;
355
+ /**
356
+ * Download file by streaming it from the file path. This method will setup
357
+ * appropriate `Content-type`, `Content-type` and `Last-modified` headers.
358
+ *
359
+ * Unexpected stream errors are handled gracefully to avoid memory leaks.
360
+ *
361
+ * If `raiseErrors=false`, then this method will self handle all the exceptions by
362
+ * writing a generic HTTP response. To have more control over the error, it is
363
+ * recommended to set `raiseErrors=true` and wrap this function inside a
364
+ * `try/catch` statement.
365
+ *
366
+ * @example
367
+ * ```js
368
+ * // Errors handled automatically with generic HTTP response
369
+ * response.download('somefile.jpg')
370
+ *
371
+ * // Manually handle (note the await call)
372
+ * try {
373
+ * await response.download('somefile.jpg')
374
+ * } catch (error) {
375
+ * response.status(error.code === 'ENOENT' ? 404 : 500)
376
+ * response.send('Cannot process file')
377
+ * }
378
+ * ```
379
+ */
380
+ download(filePath: string, generateEtag?: boolean, errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]): void;
381
+ /**
382
+ * Download the file by forcing the user to save the file vs displaying it
383
+ * within the browser.
384
+ *
385
+ * Internally calls [[download]]
386
+ */
387
+ attachment(filePath: string, name?: string, disposition?: string, generateEtag?: boolean, errorCallback?: (error: NodeJS.ErrnoException) => [string, number?]): void;
388
+ /**
389
+ * Set the location header.
390
+ *
391
+ * @example
392
+ * ```js
393
+ * response.location('/login')
394
+ * ```
395
+ */
396
+ location(url: string): this;
397
+ /**
398
+ * Redirect the request.
399
+ *
400
+ * @example
401
+ * ```js
402
+ * response.redirect('/foo')
403
+ * response.redirect().toRoute('foo.bar')
404
+ * response.redirect().back()
405
+ * ```
406
+ */
407
+ redirect(): Redirect;
408
+ redirect(path: string, forwardQueryString?: boolean, statusCode?: number): void;
409
+ /**
410
+ * Abort the request with custom body and a status code. 400 is
411
+ * used when status is not defined
412
+ */
413
+ abort(body: any, status?: number): never;
414
+ /**
415
+ * Abort the request with custom body and a status code when
416
+ * passed condition returns `true`
417
+ */
418
+ abortIf(condition: unknown, body: any, status?: number): asserts condition is undefined | null | false;
419
+ /**
420
+ * Abort the request with custom body and a status code when
421
+ * passed condition returns `false`
422
+ */
423
+ abortUnless<T>(condition: T, body: any, status?: number): asserts condition is Exclude<T, undefined | null | false>;
424
+ /**
425
+ * Set signed cookie as the response header. The inline options overrides
426
+ * all options from the config.
427
+ */
428
+ cookie(key: string, value: any, options?: Partial<CookieOptions>): this;
429
+ /**
430
+ * Set encrypted cookie as the response header. The inline options overrides
431
+ * all options from the config.
432
+ */
433
+ encryptedCookie(key: string, value: any, options?: Partial<CookieOptions>): this;
434
+ /**
435
+ * Set unsigned cookie as the response header. The inline options overrides
436
+ * all options from the config.
437
+ */
438
+ plainCookie(key: string, value: any, options?: Partial<CookieOptions & {
439
+ encode: boolean;
440
+ }>): this;
441
+ /**
442
+ * Clear existing cookie.
443
+ */
444
+ clearCookie(key: string, options?: Partial<CookieOptions>): this;
445
+ /**
446
+ * Finishes the response by writing the lazy body, when `explicitEnd = true`
447
+ * and response is already pending.
448
+ *
449
+ * Calling this method twice or when `explicitEnd = false` is noop.
450
+ */
451
+ finish(): void;
452
+ /**
453
+ * Shorthand method to finish request with "100" status code
454
+ */
455
+ continue(): void;
456
+ /**
457
+ * Shorthand method to finish request with "101" status code
458
+ */
459
+ switchingProtocols(): void;
460
+ /**
461
+ * Shorthand method to finish request with "200" status code
462
+ */
463
+ ok(body: any, generateEtag?: boolean): void;
464
+ /**
465
+ * Shorthand method to finish request with "201" status code
466
+ */
467
+ created(body?: any, generateEtag?: boolean): void;
468
+ /**
469
+ * Shorthand method to finish request with "202" status code
470
+ */
471
+ accepted(body: any, generateEtag?: boolean): void;
472
+ /**
473
+ * Shorthand method to finish request with "203" status code
474
+ */
475
+ nonAuthoritativeInformation(body: any, generateEtag?: boolean): void;
476
+ /**
477
+ * Shorthand method to finish request with "204" status code
478
+ */
479
+ noContent(): void;
480
+ /**
481
+ * Shorthand method to finish request with "205" status code
482
+ */
483
+ resetContent(): void;
484
+ /**
485
+ * Shorthand method to finish request with "206" status code
486
+ */
487
+ partialContent(body: any, generateEtag?: boolean): void;
488
+ /**
489
+ * Shorthand method to finish request with "300" status code
490
+ */
491
+ multipleChoices(body?: any, generateEtag?: boolean): void;
492
+ /**
493
+ * Shorthand method to finish request with "301" status code
494
+ */
495
+ movedPermanently(body?: any, generateEtag?: boolean): void;
496
+ /**
497
+ * Shorthand method to finish request with "302" status code
498
+ */
499
+ movedTemporarily(body?: any, generateEtag?: boolean): void;
500
+ /**
501
+ * Shorthand method to finish request with "303" status code
502
+ */
503
+ seeOther(body?: any, generateEtag?: boolean): void;
504
+ /**
505
+ * Shorthand method to finish request with "304" status code
506
+ */
507
+ notModified(body?: any, generateEtag?: boolean): void;
508
+ /**
509
+ * Shorthand method to finish request with "305" status code
510
+ */
511
+ useProxy(body?: any, generateEtag?: boolean): void;
512
+ /**
513
+ * Shorthand method to finish request with "307" status code
514
+ */
515
+ temporaryRedirect(body?: any, generateEtag?: boolean): void;
516
+ /**
517
+ * Shorthand method to finish request with "400" status code
518
+ */
519
+ badRequest(body?: any, generateEtag?: boolean): void;
520
+ /**
521
+ * Shorthand method to finish request with "401" status code
522
+ */
523
+ unauthorized(body?: any, generateEtag?: boolean): void;
524
+ /**
525
+ * Shorthand method to finish request with "402" status code
526
+ */
527
+ paymentRequired(body?: any, generateEtag?: boolean): void;
528
+ /**
529
+ * Shorthand method to finish request with "403" status code
530
+ */
531
+ forbidden(body?: any, generateEtag?: boolean): void;
532
+ /**
533
+ * Shorthand method to finish request with "404" status code
534
+ */
535
+ notFound(body?: any, generateEtag?: boolean): void;
536
+ /**
537
+ * Shorthand method to finish request with "405" status code
538
+ */
539
+ methodNotAllowed(body?: any, generateEtag?: boolean): void;
540
+ /**
541
+ * Shorthand method to finish request with "406" status code
542
+ */
543
+ notAcceptable(body?: any, generateEtag?: boolean): void;
544
+ /**
545
+ * Shorthand method to finish request with "407" status code
546
+ */
547
+ proxyAuthenticationRequired(body?: any, generateEtag?: boolean): void;
548
+ /**
549
+ * Shorthand method to finish request with "408" status code
550
+ */
551
+ requestTimeout(body?: any, generateEtag?: boolean): void;
552
+ /**
553
+ * Shorthand method to finish request with "409" status code
554
+ */
555
+ conflict(body?: any, generateEtag?: boolean): void;
556
+ /**
557
+ * Shorthand method to finish request with "401" status code
558
+ */
559
+ gone(body?: any, generateEtag?: boolean): void;
560
+ /**
561
+ * Shorthand method to finish request with "411" status code
562
+ */
563
+ lengthRequired(body?: any, generateEtag?: boolean): void;
564
+ /**
565
+ * Shorthand method to finish request with "412" status code
566
+ */
567
+ preconditionFailed(body?: any, generateEtag?: boolean): void;
568
+ /**
569
+ * Shorthand method to finish request with "413" status code
570
+ */
571
+ requestEntityTooLarge(body?: any, generateEtag?: boolean): void;
572
+ /**
573
+ * Shorthand method to finish request with "414" status code
574
+ */
575
+ requestUriTooLong(body?: any, generateEtag?: boolean): void;
576
+ /**
577
+ * Shorthand method to finish request with "415" status code
578
+ */
579
+ unsupportedMediaType(body?: any, generateEtag?: boolean): void;
580
+ /**
581
+ * Shorthand method to finish request with "416" status code
582
+ */
583
+ requestedRangeNotSatisfiable(body?: any, generateEtag?: boolean): void;
584
+ /**
585
+ * Shorthand method to finish request with "417" status code
586
+ */
587
+ expectationFailed(body?: any, generateEtag?: boolean): void;
588
+ /**
589
+ * Shorthand method to finish request with "422" status code
590
+ */
591
+ unprocessableEntity(body?: any, generateEtag?: boolean): void;
592
+ /**
593
+ * Shorthand method to finish request with "429" status code
594
+ */
595
+ tooManyRequests(body?: any, generateEtag?: boolean): void;
596
+ /**
597
+ * Shorthand method to finish request with "500" status code
598
+ */
599
+ internalServerError(body?: any, generateEtag?: boolean): void;
600
+ /**
601
+ * Shorthand method to finish request with "501" status code
602
+ */
603
+ notImplemented(body?: any, generateEtag?: boolean): void;
604
+ /**
605
+ * Shorthand method to finish request with "502" status code
606
+ */
607
+ badGateway(body?: any, generateEtag?: boolean): void;
608
+ /**
609
+ * Shorthand method to finish request with "503" status code
610
+ */
611
+ serviceUnavailable(body?: any, generateEtag?: boolean): void;
612
+ /**
613
+ * Shorthand method to finish request with "504" status code
614
+ */
615
+ gatewayTimeout(body?: any, generateEtag?: boolean): void;
616
+ /**
617
+ * Shorthand method to finish request with "505" status code
618
+ */
619
+ httpVersionNotSupported(body?: any, generateEtag?: boolean): void;
620
+ }
@@ -0,0 +1,42 @@
1
+ import Macroable from '@poppinss/macroable';
2
+ import type { Application } from '@adonisjs/application';
3
+ import { Route } from './route.js';
4
+ import type { ParsedGlobalMiddleware } from '../types/middleware.js';
5
+ import type { MakeUrlOptions, RouteFn, RouteMatchers } from '../types/route.js';
6
+ /**
7
+ * Brisk routes exposes the API to configure the route handler by chaining
8
+ * one of the pre-defined methods.
9
+ *
10
+ * For example: Instead of defining the redirect logic as a callback, one can
11
+ * chain the `.redirect` method.
12
+ *
13
+ * Brisk routes are always registered under the `GET` HTTP method.
14
+ */
15
+ export declare class BriskRoute extends Macroable {
16
+ #private;
17
+ /**
18
+ * Reference to route instance. Set after `setHandler` is called
19
+ */
20
+ route: null | Route;
21
+ constructor(app: Application<any>, routerMiddleware: ParsedGlobalMiddleware[], options: {
22
+ pattern: string;
23
+ globalMatchers: RouteMatchers;
24
+ });
25
+ /**
26
+ * Set handler for the brisk route
27
+ */
28
+ setHandler(handler: RouteFn): Route;
29
+ /**
30
+ * Redirects to a given route. Params from the original request will
31
+ * be used when no custom params are defined.
32
+ */
33
+ redirect(identifier: string, params?: any[] | Record<string, any>, options?: MakeUrlOptions & {
34
+ status: number;
35
+ }): Route;
36
+ /**
37
+ * Redirect request to a fixed URL
38
+ */
39
+ redirectToPath(url: string, options?: {
40
+ status: number;
41
+ }): Route;
42
+ }
@@ -0,0 +1,9 @@
1
+ import type { ContainerResolver } from '@adonisjs/fold';
2
+ import type { StoreRouteNode } from '../types/route.js';
3
+ import type { HttpContext } from '../http_context/main.js';
4
+ import type { ServerErrorHandler } from '../types/server.js';
5
+ /**
6
+ * Executor to execute the route middleware pipeline the route
7
+ * handler
8
+ */
9
+ export declare function execute(route: StoreRouteNode, resolver: ContainerResolver<any>, ctx: HttpContext, errorResponder: ServerErrorHandler['handle']): Promise<void>;
@@ -0,0 +1,6 @@
1
+ import type { HttpContext } from '../../http_context/main.js';
2
+ /**
3
+ * A factory function that uses the return value of the request
4
+ * pipeline as the response
5
+ */
6
+ export declare function useReturnValue(ctx: HttpContext): (value: any) => void;