@adonisjs/http-server 8.0.0-next.4 → 8.0.0-next.6

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 (56) hide show
  1. package/build/{chunk-BFGF3A5X.js → chunk-7ROFCP6L.js} +1095 -548
  2. package/build/{chunk-ASX56VAK.js → chunk-NQNHMINZ.js} +59 -0
  3. package/build/factories/http_context.d.ts +2 -1
  4. package/build/factories/http_server.d.ts +7 -0
  5. package/build/factories/main.js +31 -5
  6. package/build/factories/qs_parser_factory.d.ts +3 -2
  7. package/build/factories/request.d.ts +1 -0
  8. package/build/factories/response.d.ts +1 -0
  9. package/build/factories/router.d.ts +1 -0
  10. package/build/factories/server_factory.d.ts +1 -0
  11. package/build/factories/url_builder_factory.d.ts +1 -0
  12. package/build/index.d.ts +3 -1
  13. package/build/index.js +87 -37
  14. package/build/src/cookies/client.d.ts +35 -0
  15. package/build/src/cookies/drivers/encrypted.d.ts +13 -0
  16. package/build/src/cookies/drivers/plain.d.ts +9 -0
  17. package/build/src/cookies/drivers/signed.d.ts +13 -0
  18. package/build/src/cookies/parser.d.ts +18 -0
  19. package/build/src/cookies/serializer.d.ts +20 -0
  20. package/build/src/define_config.d.ts +1 -3
  21. package/build/src/define_middleware.d.ts +1 -1
  22. package/build/src/exception_handler.d.ts +72 -31
  23. package/build/src/helpers.d.ts +50 -0
  24. package/build/src/helpers.js +5 -1
  25. package/build/src/http_context/local_storage.d.ts +17 -0
  26. package/build/src/http_context/main.d.ts +8 -0
  27. package/build/src/qs.d.ts +14 -0
  28. package/build/src/redirect.d.ts +27 -11
  29. package/build/src/request.d.ts +109 -10
  30. package/build/src/response.d.ts +399 -203
  31. package/build/src/router/brisk.d.ts +15 -4
  32. package/build/src/router/executor.d.ts +4 -0
  33. package/build/src/router/factories/use_return_value.d.ts +5 -0
  34. package/build/src/router/group.d.ts +17 -0
  35. package/build/src/router/legacy/url_builder.d.ts +7 -0
  36. package/build/src/router/main.d.ts +72 -1
  37. package/build/src/router/matchers.d.ts +3 -0
  38. package/build/src/router/resource.d.ts +33 -0
  39. package/build/src/router/route.d.ts +8 -0
  40. package/build/src/router/signed_url_builder.d.ts +4 -8
  41. package/build/src/router/store.d.ts +9 -0
  42. package/build/src/router/url_builder.d.ts +4 -9
  43. package/build/src/server/factories/middleware_handler.d.ts +10 -1
  44. package/build/src/server/factories/route_finder.d.ts +13 -3
  45. package/build/src/server/factories/write_response.d.ts +9 -2
  46. package/build/src/server/main.d.ts +77 -23
  47. package/build/src/tracing_channels.d.ts +4 -4
  48. package/build/src/types/middleware.d.ts +33 -8
  49. package/build/src/types/qs.d.ts +5 -0
  50. package/build/src/types/request.d.ts +1 -1
  51. package/build/src/types/response.d.ts +14 -6
  52. package/build/src/types/route.d.ts +40 -17
  53. package/build/src/types/server.d.ts +26 -11
  54. package/build/src/types/tracing_channels.d.ts +21 -3
  55. package/build/src/types/url_builder.d.ts +41 -28
  56. package/package.json +15 -13
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  __export,
3
+ createSignedURL,
4
+ createURL,
3
5
  default as default2,
4
6
  default2 as default3,
5
7
  parseRoute,
6
8
  serializeCookie
7
- } from "./chunk-ASX56VAK.js";
9
+ } from "./chunk-NQNHMINZ.js";
8
10
 
9
11
  // src/errors.ts
10
12
  var errors_exports = {};
@@ -107,42 +109,76 @@ function unpack3(key, encryptedValue, encryption) {
107
109
 
108
110
  // src/cookies/client.ts
109
111
  var CookieClient = class {
112
+ /**
113
+ * Private encryption instance used for signing and encrypting cookies
114
+ */
110
115
  #encryption;
116
+ /**
117
+ * Create a new instance of CookieClient
118
+ *
119
+ * @param encryption - The encryption instance for cookie operations
120
+ */
111
121
  constructor(encryption) {
112
122
  this.#encryption = encryption;
113
123
  }
114
124
  /**
115
125
  * Encrypt a key value pair to be sent in the cookie header
126
+ *
127
+ * @param key - The cookie key
128
+ * @param value - The value to encrypt
129
+ * @returns The encrypted cookie string or null if encryption fails
116
130
  */
117
131
  encrypt(key, value) {
118
132
  return pack3(key, value, this.#encryption);
119
133
  }
120
134
  /**
121
135
  * Sign a key value pair to be sent in the cookie header
136
+ *
137
+ * @param key - The cookie key
138
+ * @param value - The value to sign
139
+ * @returns The signed cookie string or null if signing fails
122
140
  */
123
141
  sign(key, value) {
124
142
  return pack2(key, value, this.#encryption);
125
143
  }
126
144
  /**
127
145
  * Encode a key value pair to be sent in the cookie header
146
+ *
147
+ * @param _ - Unused key parameter
148
+ * @param value - The value to encode
149
+ * @param stringify - Whether to stringify the value before encoding
150
+ * @returns The encoded cookie string or null if encoding fails
128
151
  */
129
152
  encode(_, value, stringify2 = true) {
130
153
  return stringify2 ? pack(value) : value;
131
154
  }
132
155
  /**
133
156
  * Unsign a signed cookie value
157
+ *
158
+ * @param key - The cookie key
159
+ * @param value - The signed cookie value to unsign
160
+ * @returns The original value if valid signature, null otherwise
134
161
  */
135
162
  unsign(key, value) {
136
163
  return canUnpack2(value) ? unpack2(key, value, this.#encryption) : null;
137
164
  }
138
165
  /**
139
166
  * Decrypt an encrypted cookie value
167
+ *
168
+ * @param key - The cookie key
169
+ * @param value - The encrypted cookie value to decrypt
170
+ * @returns The decrypted value or null if decryption fails
140
171
  */
141
172
  decrypt(key, value) {
142
173
  return canUnpack3(value) ? unpack3(key, value, this.#encryption) : null;
143
174
  }
144
175
  /**
145
176
  * Decode an encoded cookie value
177
+ *
178
+ * @param _ - Unused key parameter
179
+ * @param value - The encoded cookie value to decode
180
+ * @param stringified - Whether the value was stringified during encoding
181
+ * @returns The decoded value or null if decoding fails
146
182
  */
147
183
  decode(_, value, stringified = true) {
148
184
  if (!stringified) {
@@ -152,6 +188,10 @@ var CookieClient = class {
152
188
  }
153
189
  /**
154
190
  * Parse response cookie
191
+ *
192
+ * @param key - The cookie key
193
+ * @param value - The cookie value to parse
194
+ * @returns The parsed value or undefined if parsing fails
155
195
  */
156
196
  parse(key, value) {
157
197
  if (canUnpack2(value)) {
@@ -166,6 +206,129 @@ var CookieClient = class {
166
206
  }
167
207
  };
168
208
 
209
+ // src/cookies/parser.ts
210
+ import cookie from "cookie";
211
+ var CookieParser = class {
212
+ /**
213
+ * Cookie client instance for handling cookie operations
214
+ */
215
+ #client;
216
+ /**
217
+ * A copy of cached cookies, they are cached during a request after
218
+ * initial decoding, unsigning or decrypting.
219
+ */
220
+ #cachedCookies = {
221
+ signedCookies: {},
222
+ plainCookies: {},
223
+ encryptedCookies: {}
224
+ };
225
+ /**
226
+ * An object of key-value pair collected by parsing
227
+ * the request cookie header.
228
+ */
229
+ #cookies;
230
+ /**
231
+ * Create a new instance of CookieParser
232
+ *
233
+ * @param cookieHeader - The raw cookie header string from the request
234
+ * @param encryption - The encryption instance for cookie operations
235
+ */
236
+ constructor(cookieHeader, encryption) {
237
+ this.#client = new CookieClient(encryption);
238
+ this.#cookies = this.#parse(cookieHeader);
239
+ }
240
+ /**
241
+ * Parses the request `cookie` header
242
+ *
243
+ * @param cookieHeader - The cookie header string to parse
244
+ * @returns Parsed cookies as key-value pairs
245
+ */
246
+ #parse(cookieHeader) {
247
+ if (!cookieHeader) {
248
+ return {};
249
+ }
250
+ return cookie.parse(cookieHeader);
251
+ }
252
+ /**
253
+ * Attempts to decode a cookie by the name. When calling this method,
254
+ * you are assuming that the cookie was just stringified in the first
255
+ * place and not signed or encrypted.
256
+ *
257
+ * @param key - The cookie key to decode
258
+ * @param stringified - Whether the cookie value was stringified
259
+ * @returns The decoded cookie value or null if decoding fails
260
+ */
261
+ decode(key, stringified = true) {
262
+ const value = this.#cookies[key];
263
+ if (value === null || value === void 0) {
264
+ return null;
265
+ }
266
+ const cache = this.#cachedCookies.plainCookies;
267
+ if (cache[key] !== void 0) {
268
+ return cache[key];
269
+ }
270
+ const parsed = this.#client.decode(key, value, stringified);
271
+ if (parsed !== null) {
272
+ cache[key] = parsed;
273
+ }
274
+ return parsed;
275
+ }
276
+ /**
277
+ * Attempts to unsign a cookie by the name. When calling this method,
278
+ * you are assuming that the cookie was signed in the first place.
279
+ *
280
+ * @param key - The cookie key to unsign
281
+ * @returns The original cookie value or null if unsigning fails
282
+ */
283
+ unsign(key) {
284
+ const value = this.#cookies[key];
285
+ if (value === null || value === void 0) {
286
+ return null;
287
+ }
288
+ const cache = this.#cachedCookies.signedCookies;
289
+ if (cache[key] !== void 0) {
290
+ return cache[key];
291
+ }
292
+ const parsed = this.#client.unsign(key, value);
293
+ if (parsed !== null) {
294
+ cache[key] = parsed;
295
+ }
296
+ return parsed;
297
+ }
298
+ /**
299
+ * Attempts to decrypt a cookie by the name. When calling this method,
300
+ * you are assuming that the cookie was encrypted in the first place.
301
+ *
302
+ * @param key - The cookie key to decrypt
303
+ * @returns The decrypted cookie value or null if decryption fails
304
+ */
305
+ decrypt(key) {
306
+ const value = this.#cookies[key];
307
+ if (value === null || value === void 0) {
308
+ return null;
309
+ }
310
+ const cache = this.#cachedCookies.encryptedCookies;
311
+ if (cache[key] !== void 0) {
312
+ return cache[key];
313
+ }
314
+ const parsed = this.#client.decrypt(key, value);
315
+ if (parsed !== null) {
316
+ cache[key] = parsed;
317
+ }
318
+ return parsed;
319
+ }
320
+ /**
321
+ * Returns an object of cookies key-value pair. Do note, the
322
+ * cookies are not decoded, unsigned or decrypted inside this
323
+ * list.
324
+ *
325
+ * @returns Raw cookies as key-value pairs
326
+ */
327
+ list() {
328
+ return this.#cookies;
329
+ }
330
+ };
331
+
169
332
  // src/tracing_channels.ts
170
333
  var tracing_channels_exports = {};
171
334
  __export(tracing_channels_exports, {
@@ -176,14 +339,14 @@ __export(tracing_channels_exports, {
176
339
  httpRouteHandler: () => httpRouteHandler
177
340
  });
178
341
  import diagnostics_channel from "diagnostics_channel";
179
- var httpRequest = diagnostics_channel.tracingChannel("adonisjs:http.request");
180
- var httpMiddleware = diagnostics_channel.tracingChannel("adonisjs:http.middleware");
342
+ var httpRequest = diagnostics_channel.tracingChannel("adonisjs.http.request");
343
+ var httpMiddleware = diagnostics_channel.tracingChannel("adonisjs.http.middleware");
181
344
  var httpExceptionHandler = diagnostics_channel.tracingChannel(
182
- "adonisjs:http.exception.handler"
345
+ "adonisjs.http.exception.handler"
183
346
  );
184
- var httpRouteHandler = diagnostics_channel.tracingChannel("adonisjs:http.route.handler");
347
+ var httpRouteHandler = diagnostics_channel.tracingChannel("adonisjs.http.route.handler");
185
348
  var httpResponseSerializer = diagnostics_channel.tracingChannel(
186
- "adonisjs:http.response.serializer"
349
+ "adonisjs.http.response.serializer"
187
350
  );
188
351
 
189
352
  // src/router/route.ts
@@ -217,14 +380,14 @@ function execute(route, resolver, ctx, errorResponder) {
217
380
  if (typeof route.handler === "function") {
218
381
  return httpRouteHandler.tracePromise(
219
382
  ($ctx) => Promise.resolve(route.handler($ctx)),
220
- route,
383
+ httpRouteHandler.hasSubscribers ? { route } : void 0,
221
384
  void 0,
222
385
  ctx
223
386
  ).then(useReturnValue(ctx));
224
387
  }
225
388
  return httpRouteHandler.tracePromise(
226
389
  route.handler.handle,
227
- route,
390
+ httpRouteHandler.hasSubscribers ? { route } : void 0,
228
391
  void 0,
229
392
  resolver,
230
393
  ctx
@@ -233,7 +396,7 @@ function execute(route, resolver, ctx, errorResponder) {
233
396
  if (typeof middleware === "function") {
234
397
  return httpMiddleware.tracePromise(
235
398
  middleware,
236
- middleware,
399
+ httpMiddleware.hasSubscribers ? { middleware } : void 0,
237
400
  void 0,
238
401
  ctx,
239
402
  next
@@ -241,7 +404,7 @@ function execute(route, resolver, ctx, errorResponder) {
241
404
  }
242
405
  return httpMiddleware.tracePromise(
243
406
  middleware.handle,
244
- middleware,
407
+ httpMiddleware.hasSubscribers ? { middleware } : void 0,
245
408
  void 0,
246
409
  resolver,
247
410
  ctx,
@@ -281,6 +444,12 @@ var BriskRoute = class extends Macroable {
281
444
  * Reference to route instance. Set after `setHandler` is called
282
445
  */
283
446
  route = null;
447
+ /**
448
+ * Creates a new BriskRoute instance
449
+ * @param app - The AdonisJS application instance
450
+ * @param routerMiddleware - Array of global middleware registered on the router
451
+ * @param options - Configuration options for the brisk route
452
+ */
284
453
  constructor(app, routerMiddleware, options) {
285
454
  super();
286
455
  this.#app = app;
@@ -290,6 +459,8 @@ var BriskRoute = class extends Macroable {
290
459
  }
291
460
  /**
292
461
  * Set handler for the brisk route
462
+ * @param handler - The route handler function
463
+ * @returns The created route instance
293
464
  */
294
465
  setHandler(handler) {
295
466
  this.route = new Route(this.#app, this.#routerMiddleware, {
@@ -303,6 +474,8 @@ var BriskRoute = class extends Macroable {
303
474
  /**
304
475
  * Redirects to a given route. Params from the original request will
305
476
  * be used when no custom params are defined.
477
+ * @param args - Route identifier, parameters, and options for building the redirect URL
478
+ * @returns The created route instance
306
479
  */
307
480
  redirect(...args) {
308
481
  const [identifier, params, options] = args;
@@ -318,6 +491,9 @@ var BriskRoute = class extends Macroable {
318
491
  }
319
492
  /**
320
493
  * Redirect request to a fixed URL
494
+ * @param url - The URL to redirect to
495
+ * @param options - Optional redirect options including HTTP status code
496
+ * @returns The created route instance
321
497
  */
322
498
  redirectToPath(url, options) {
323
499
  function redirectsToPath(ctx) {
@@ -378,6 +554,12 @@ var RouteResource = class extends Macroable2 {
378
554
  * A collection of routes instances that belongs to this resource
379
555
  */
380
556
  routes = [];
557
+ /**
558
+ * Creates a new RouteResource instance
559
+ * @param app - The AdonisJS application instance
560
+ * @param routerMiddleware - Array of global middleware registered on the router
561
+ * @param options - Configuration options for the route resource
562
+ */
381
563
  constructor(app, routerMiddleware, options) {
382
564
  super();
383
565
  this.#validateResourceName(options.resource);
@@ -468,6 +650,8 @@ var RouteResource = class extends Macroable2 {
468
650
  }
469
651
  /**
470
652
  * Register only given routes and remove others
653
+ * @param names - Array of action names to keep
654
+ * @returns Current RouteResource instance with filtered actions
471
655
  */
472
656
  only(names) {
473
657
  this.#filter(names, true).forEach((route) => route.markAsDeleted());
@@ -475,6 +659,8 @@ var RouteResource = class extends Macroable2 {
475
659
  }
476
660
  /**
477
661
  * Register all routes, except the one's defined
662
+ * @param names - Array of action names to exclude
663
+ * @returns Current RouteResource instance with filtered actions
478
664
  */
479
665
  except(names) {
480
666
  this.#filter(names, false).forEach((route) => route.markAsDeleted());
@@ -483,12 +669,16 @@ var RouteResource = class extends Macroable2 {
483
669
  /**
484
670
  * Register api only routes. The `create` and `edit` routes, which
485
671
  * are meant to show forms will not be registered
672
+ * @returns Current RouteResource instance without create and edit actions
486
673
  */
487
674
  apiOnly() {
488
675
  return this.except(["create", "edit"]);
489
676
  }
490
677
  /**
491
678
  * Define matcher for params inside the resource
679
+ * @param key - The parameter name to match
680
+ * @param matcher - The matcher pattern (RegExp, string, or RouteMatcher)
681
+ * @returns Current RouteResource instance for method chaining
492
682
  */
493
683
  where(key, matcher) {
494
684
  this.routes.forEach((route) => {
@@ -514,6 +704,8 @@ var RouteResource = class extends Macroable2 {
514
704
  }
515
705
  /**
516
706
  * Set the param name for a given resource
707
+ * @param resources - Object mapping resource names to parameter names
708
+ * @returns Current RouteResource instance for method chaining
517
709
  */
518
710
  params(resources) {
519
711
  Object.keys(resources).forEach((resource) => {
@@ -534,6 +726,9 @@ var RouteResource = class extends Macroable2 {
534
726
  *
535
727
  * Calling this method multiple times will append middleware
536
728
  * to existing list.
729
+ * @param actions - Action name(s) or '*' for all actions
730
+ * @param middleware - Middleware function(s) to apply
731
+ * @returns Current RouteResource instance for method chaining
537
732
  */
538
733
  use(actions, middleware) {
539
734
  if (actions === "*") {
@@ -545,12 +740,18 @@ var RouteResource = class extends Macroable2 {
545
740
  }
546
741
  /**
547
742
  * @alias use
743
+ * @param actions - Action name(s) or '*' for all actions
744
+ * @param middleware - Middleware function(s) to apply
745
+ * @returns Current RouteResource instance for method chaining
548
746
  */
549
747
  middleware(actions, middleware) {
550
748
  return this.use(actions, middleware);
551
749
  }
552
750
  /**
553
751
  * Prepend name to all the routes
752
+ * @param name - The name to prepend to all route names
753
+ * @param normalizeName - Whether to normalize the name to snake_case
754
+ * @returns Current RouteResource instance for method chaining
554
755
  */
555
756
  as(name, normalizeName = true) {
556
757
  name = normalizeName ? string.snakeCase(name) : name;
@@ -564,6 +765,10 @@ var RouteResource = class extends Macroable2 {
564
765
 
565
766
  // src/router/group.ts
566
767
  var RouteGroup = class _RouteGroup extends Macroable3 {
768
+ /**
769
+ * Creates a new RouteGroup instance
770
+ * @param routes - Array of routes that belong to this group
771
+ */
567
772
  constructor(routes) {
568
773
  super();
569
774
  this.routes = routes;
@@ -679,6 +884,9 @@ var RouteGroup = class _RouteGroup extends Macroable3 {
679
884
  * Route.group(() => {
680
885
  * }).where('id', /^[0-9]+/)
681
886
  * ```
887
+ * @param param - The parameter name to match
888
+ * @param matcher - The matcher pattern (RegExp, string, or RouteMatcher)
889
+ * @returns Current RouteGroup instance for method chaining
682
890
  */
683
891
  where(param, matcher) {
684
892
  this.routes.forEach((route) => this.#updateRouteMatchers(route, param, matcher));
@@ -691,6 +899,8 @@ var RouteGroup = class _RouteGroup extends Macroable3 {
691
899
  * Route.group(() => {
692
900
  * }).prefix('v1')
693
901
  * ```
902
+ * @param prefix - The prefix to add to all routes in the group
903
+ * @returns Current RouteGroup instance for method chaining
694
904
  */
695
905
  prefix(prefix) {
696
906
  this.routes.forEach((route) => this.#setRoutePrefix(route, prefix));
@@ -703,6 +913,8 @@ var RouteGroup = class _RouteGroup extends Macroable3 {
703
913
  * Route.group(() => {
704
914
  * }).domain(':name.adonisjs.com')
705
915
  * ```
916
+ * @param domain - The domain pattern for all routes in the group
917
+ * @returns Current RouteGroup instance for method chaining
706
918
  */
707
919
  domain(domain) {
708
920
  this.routes.forEach((route) => this.#updateRouteDomain(route, domain));
@@ -715,6 +927,8 @@ var RouteGroup = class _RouteGroup extends Macroable3 {
715
927
  * Route.group(() => {
716
928
  * }).as('version1')
717
929
  * ```
930
+ * @param name - The name to prepend to all route names in the group
931
+ * @returns Current RouteGroup instance for method chaining
718
932
  */
719
933
  as(name) {
720
934
  this.routes.forEach((route) => this.#updateRouteName(route, name));
@@ -727,6 +941,8 @@ var RouteGroup = class _RouteGroup extends Macroable3 {
727
941
  * Route.group(() => {
728
942
  * }).use(middleware.auth())
729
943
  * ```
944
+ * @param middleware - Middleware function(s) to apply to all routes in the group
945
+ * @returns Current RouteGroup instance for method chaining
730
946
  */
731
947
  use(middleware) {
732
948
  if (!this.#middleware.length) {
@@ -743,6 +959,8 @@ var RouteGroup = class _RouteGroup extends Macroable3 {
743
959
  }
744
960
  /**
745
961
  * @alias use
962
+ * @param middleware - Middleware function(s) to apply to all routes in the group
963
+ * @returns Current RouteGroup instance for method chaining
746
964
  */
747
965
  middleware(middleware) {
748
966
  return this.use(middleware);
@@ -934,6 +1152,12 @@ var Route = class extends Macroable4 {
934
1152
  * routes. We mantain an array for each layer of the stack
935
1153
  */
936
1154
  #middleware = [];
1155
+ /**
1156
+ * Creates a new Route instance
1157
+ * @param app - The AdonisJS application instance
1158
+ * @param routerMiddleware - Array of global middleware registered on the router
1159
+ * @param options - Configuration options for the route
1160
+ */
937
1161
  constructor(app, routerMiddleware, options) {
938
1162
  super();
939
1163
  this.#app = app;
@@ -1037,6 +1261,8 @@ var Route = class extends Macroable4 {
1037
1261
  /**
1038
1262
  * Define prefix for the route. Calling this method multiple times
1039
1263
  * applies multiple prefixes in the reverse order.
1264
+ * @param prefix - The prefix to add to the route
1265
+ * @returns Current Route instance for method chaining
1040
1266
  */
1041
1267
  prefix(prefix) {
1042
1268
  this.#prefixes.push(prefix);
@@ -1175,108 +1401,15 @@ import proxyaddr from "proxy-addr";
1175
1401
  import { safeEqual } from "@poppinss/utils";
1176
1402
  import Macroable5 from "@poppinss/macroable";
1177
1403
  import lodash from "@poppinss/utils/lodash";
1178
-
1179
- // src/cookies/parser.ts
1180
- import cookie from "cookie";
1181
- var CookieParser = class {
1182
- #client;
1183
- /**
1184
- * A copy of cached cookies, they are cached during a request after
1185
- * initial decoding, unsigning or decrypting.
1186
- */
1187
- #cachedCookies = {
1188
- signedCookies: {},
1189
- plainCookies: {},
1190
- encryptedCookies: {}
1191
- };
1192
- /**
1193
- * An object of key-value pair collected by parsing
1194
- * the request cookie header.
1195
- */
1196
- #cookies;
1197
- constructor(cookieHeader, encryption) {
1198
- this.#client = new CookieClient(encryption);
1199
- this.#cookies = this.#parse(cookieHeader);
1200
- }
1201
- /**
1202
- * Parses the request `cookie` header
1203
- */
1204
- #parse(cookieHeader) {
1205
- if (!cookieHeader) {
1206
- return {};
1207
- }
1208
- return cookie.parse(cookieHeader);
1209
- }
1210
- /**
1211
- * Attempts to decode a cookie by the name. When calling this method,
1212
- * you are assuming that the cookie was just stringified in the first
1213
- * place and not signed or encrypted.
1214
- */
1215
- decode(key, stringified = true) {
1216
- const value = this.#cookies[key];
1217
- if (value === null || value === void 0) {
1218
- return null;
1219
- }
1220
- const cache = this.#cachedCookies.plainCookies;
1221
- if (cache[key] !== void 0) {
1222
- return cache[key];
1223
- }
1224
- const parsed = this.#client.decode(key, value, stringified);
1225
- if (parsed !== null) {
1226
- cache[key] = parsed;
1227
- }
1228
- return parsed;
1229
- }
1230
- /**
1231
- * Attempts to unsign a cookie by the name. When calling this method,
1232
- * you are assuming that the cookie was signed in the first place.
1233
- */
1234
- unsign(key) {
1235
- const value = this.#cookies[key];
1236
- if (value === null || value === void 0) {
1237
- return null;
1238
- }
1239
- const cache = this.#cachedCookies.signedCookies;
1240
- if (cache[key] !== void 0) {
1241
- return cache[key];
1242
- }
1243
- const parsed = this.#client.unsign(key, value);
1244
- if (parsed !== null) {
1245
- cache[key] = parsed;
1246
- }
1247
- return parsed;
1248
- }
1249
- /**
1250
- * Attempts to decrypt a cookie by the name. When calling this method,
1251
- * you are assuming that the cookie was encrypted in the first place.
1252
- */
1253
- decrypt(key) {
1254
- const value = this.#cookies[key];
1255
- if (value === null || value === void 0) {
1256
- return null;
1257
- }
1258
- const cache = this.#cachedCookies.encryptedCookies;
1259
- if (cache[key] !== void 0) {
1260
- return cache[key];
1261
- }
1262
- const parsed = this.#client.decrypt(key, value);
1263
- if (parsed !== null) {
1264
- cache[key] = parsed;
1265
- }
1266
- return parsed;
1267
- }
1404
+ var Request = class extends Macroable5 {
1268
1405
  /**
1269
- * Returns an object of cookies key-value pair. Do note, the
1270
- * cookies are not decoded, unsigned or decrypted inside this
1271
- * list.
1406
+ * Creates a new Request instance wrapping the native Node.js HTTP request
1407
+ * @param request - Native Node.js incoming message instance
1408
+ * @param response - Native Node.js server response instance
1409
+ * @param encryption - Encryption module for cookie and URL signing
1410
+ * @param config - Request configuration options
1411
+ * @param qsParser - Query string parser instance
1272
1412
  */
1273
- list() {
1274
- return this.#cookies;
1275
- }
1276
- };
1277
-
1278
- // src/request.ts
1279
- var Request = class extends Macroable5 {
1280
1413
  constructor(request, response, encryption, config, qsParser) {
1281
1414
  super();
1282
1415
  this.request = request;
@@ -1331,16 +1464,15 @@ var Request = class extends Macroable5 {
1331
1464
  */
1332
1465
  #cookieParser;
1333
1466
  /**
1334
- * Parsed URL with query string stored as a string.
1467
+ * Parsed URL with query string stored as a string and decode flag
1335
1468
  */
1336
1469
  parsedUrl;
1337
1470
  /**
1338
- * The ctx will be set by the context itself. It creates a circular
1339
- * reference
1471
+ * HTTP context reference - creates a circular reference when set by the context
1340
1472
  */
1341
1473
  ctx;
1342
1474
  /**
1343
- * Parses the query string
1475
+ * Parses the query string from the parsed URL and updates internal state
1344
1476
  */
1345
1477
  #parseQueryString() {
1346
1478
  if (this.parsedUrl.query) {
@@ -1349,7 +1481,7 @@ var Request = class extends Macroable5 {
1349
1481
  }
1350
1482
  }
1351
1483
  /**
1352
- * Initiates the cookie parser lazily
1484
+ * Initiates the cookie parser lazily when first needed
1353
1485
  */
1354
1486
  #initiateCookieParser() {
1355
1487
  if (!this.#cookieParser) {
@@ -1367,6 +1499,7 @@ var Request = class extends Macroable5 {
1367
1499
  /**
1368
1500
  * Returns the request id from the `x-request-id` header. The
1369
1501
  * header is untouched, if it already exists.
1502
+ * @returns The request ID or undefined if not found/generated
1370
1503
  */
1371
1504
  id() {
1372
1505
  let requestId = this.header("x-request-id");
@@ -1383,6 +1516,8 @@ var Request = class extends Macroable5 {
1383
1516
  *
1384
1517
  * This method is supposed to be invoked by the body parser and must be called only
1385
1518
  * once. For further mutations make use of `updateBody` method.
1519
+ * @param body - Parsed request body data
1520
+ * @returns {void}
1386
1521
  */
1387
1522
  setInitialBody(body) {
1388
1523
  if (this.#originalRequestData && Object.isFrozen(this.#originalRequestData)) {
@@ -1395,6 +1530,8 @@ var Request = class extends Macroable5 {
1395
1530
  * Update the request body with new data object. The `all` property
1396
1531
  * will be re-computed by merging the query string and request
1397
1532
  * body.
1533
+ * @param body - New request body data to set
1534
+ * @returns {void}
1398
1535
  */
1399
1536
  updateBody(body) {
1400
1537
  this.#requestBody = body;
@@ -1403,6 +1540,8 @@ var Request = class extends Macroable5 {
1403
1540
  /**
1404
1541
  * Update the request raw body. Bodyparser sets this when unable to parse
1405
1542
  * the request body or when request is multipart/form-data.
1543
+ * @param rawBody - Raw request body as string
1544
+ * @returns {void}
1406
1545
  */
1407
1546
  updateRawBody(rawBody) {
1408
1547
  this.#rawRequestBody = rawBody;
@@ -1410,6 +1549,8 @@ var Request = class extends Macroable5 {
1410
1549
  /**
1411
1550
  * Update the query string with the new data object. The `all` property
1412
1551
  * will be re-computed by merging the query and the request body.
1552
+ * @param data - New query string data to set
1553
+ * @returns {void}
1413
1554
  */
1414
1555
  updateQs(data) {
1415
1556
  this.#requestQs = data;
@@ -1417,18 +1558,21 @@ var Request = class extends Macroable5 {
1417
1558
  }
1418
1559
  /**
1419
1560
  * Returns route params
1561
+ * @returns {Record<string, any>} Object containing route parameters
1420
1562
  */
1421
1563
  params() {
1422
1564
  return this.ctx?.params || {};
1423
1565
  }
1424
1566
  /**
1425
1567
  * Returns the query string object by reference
1568
+ * @returns {Record<string, any>} Object containing parsed query string parameters
1426
1569
  */
1427
1570
  qs() {
1428
1571
  return this.#requestQs;
1429
1572
  }
1430
1573
  /**
1431
1574
  * Returns reference to the request body
1575
+ * @returns {Record<string, any>} Object containing parsed request body
1432
1576
  */
1433
1577
  body() {
1434
1578
  return this.#requestBody;
@@ -1436,6 +1580,7 @@ var Request = class extends Macroable5 {
1436
1580
  /**
1437
1581
  * Returns reference to the merged copy of request body
1438
1582
  * and query string
1583
+ * @returns {Record<string, any>} Object containing merged request body and query parameters
1439
1584
  */
1440
1585
  all() {
1441
1586
  return this.#requestData;
@@ -1443,6 +1588,7 @@ var Request = class extends Macroable5 {
1443
1588
  /**
1444
1589
  * Returns reference to the merged copy of original request
1445
1590
  * query string and body
1591
+ * @returns {Record<string, any>} Object containing original merged request data
1446
1592
  */
1447
1593
  original() {
1448
1594
  return this.#originalRequestData;
@@ -1452,6 +1598,7 @@ var Request = class extends Macroable5 {
1452
1598
  *
1453
1599
  * Ideally you must be dealing with the parsed body accessed using [[input]], [[all]] or
1454
1600
  * [[post]] methods. The `raw` body is always a string.
1601
+ * @returns {string | null} Raw request body as string or null if not set
1455
1602
  */
1456
1603
  raw() {
1457
1604
  return this.#rawRequestBody || null;
@@ -1467,6 +1614,9 @@ var Request = class extends Macroable5 {
1467
1614
  * // with default value
1468
1615
  * request.input('username', 'virk')
1469
1616
  * ```
1617
+ * @param key - Key to lookup in request data
1618
+ * @param defaultValue - Default value when key is not found
1619
+ * @returns Value from request data or default value
1470
1620
  */
1471
1621
  input(key, defaultValue) {
1472
1622
  return lodash.get(this.#requestData, key, defaultValue);
@@ -1481,6 +1631,9 @@ var Request = class extends Macroable5 {
1481
1631
  * // with default value
1482
1632
  * request.param('id', 1)
1483
1633
  * ```
1634
+ * @param key - Parameter key to lookup
1635
+ * @param defaultValue - Default value when parameter is not found
1636
+ * @returns Value from route parameters or default value
1484
1637
  */
1485
1638
  param(key, defaultValue) {
1486
1639
  return lodash.get(this.params(), key, defaultValue);
@@ -1492,6 +1645,8 @@ var Request = class extends Macroable5 {
1492
1645
  * ```js
1493
1646
  * request.except(['_csrf'])
1494
1647
  * ```
1648
+ * @param keys - Array of keys to exclude from the result
1649
+ * @returns {Record<string, any>} Object with all request data except specified keys
1495
1650
  */
1496
1651
  except(keys) {
1497
1652
  return lodash.omit(this.#requestData, keys);
@@ -1503,6 +1658,8 @@ var Request = class extends Macroable5 {
1503
1658
  * ```js
1504
1659
  * request.only(['username', 'age'])
1505
1660
  * ```
1661
+ * @param keys - Array of keys to include in the result
1662
+ * @returns {{ [K in T]: any }} Object with only the specified keys from request data
1506
1663
  */
1507
1664
  only(keys) {
1508
1665
  return lodash.pick(this.#requestData, keys);
@@ -1516,6 +1673,7 @@ var Request = class extends Macroable5 {
1516
1673
  * ```js
1517
1674
  * request.intended()
1518
1675
  * ```
1676
+ * @returns {string} Original HTTP method from the request
1519
1677
  */
1520
1678
  intended() {
1521
1679
  return this.request.method;
@@ -1533,6 +1691,7 @@ var Request = class extends Macroable5 {
1533
1691
  * ```js
1534
1692
  * request.method()
1535
1693
  * ```
1694
+ * @returns {string} HTTP method (potentially spoofed)
1536
1695
  */
1537
1696
  method() {
1538
1697
  if (this.#config.allowMethodSpoofing && this.intended() === "POST") {
@@ -1542,6 +1701,7 @@ var Request = class extends Macroable5 {
1542
1701
  }
1543
1702
  /**
1544
1703
  * Returns a copy of headers as an object
1704
+ * @returns {IncomingHttpHeaders} Object containing all HTTP headers
1545
1705
  */
1546
1706
  headers() {
1547
1707
  return this.request.headers;
@@ -1549,6 +1709,9 @@ var Request = class extends Macroable5 {
1549
1709
  /**
1550
1710
  * Returns value for a given header key. The default value is
1551
1711
  * used when original value is `undefined`.
1712
+ * @param key - Header name to lookup
1713
+ * @param defaultValue - Default value when header is not found
1714
+ * @returns {string | undefined} Header value or default value if not found
1552
1715
  */
1553
1716
  header(key, defaultValue) {
1554
1717
  key = key.toLowerCase();
@@ -1591,6 +1754,7 @@ var Request = class extends Macroable5 {
1591
1754
  * ```
1592
1755
  *
1593
1756
  * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
1757
+ * @returns {string} Client IP address
1594
1758
  */
1595
1759
  ip() {
1596
1760
  const ipFn = this.#config.getIp;
@@ -1616,6 +1780,7 @@ var Request = class extends Macroable5 {
1616
1780
  * ```
1617
1781
  *
1618
1782
  * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
1783
+ * @returns {string[]} Array of IP addresses from most to least trusted
1619
1784
  */
1620
1785
  ips() {
1621
1786
  return proxyaddr.all(this.request, this.#config.trustProxy);
@@ -1639,6 +1804,7 @@ var Request = class extends Macroable5 {
1639
1804
  * ```
1640
1805
  *
1641
1806
  * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
1807
+ * @returns {string} Request protocol ('http' or 'https')
1642
1808
  */
1643
1809
  protocol() {
1644
1810
  if ("encrypted" in this.request.socket) {
@@ -1654,6 +1820,7 @@ var Request = class extends Macroable5 {
1654
1820
  * Returns a boolean telling if request is served over `https`
1655
1821
  * or not. Check [[protocol]] method to know how protocol is
1656
1822
  * fetched.
1823
+ * @returns {boolean} True if request is served over HTTPS
1657
1824
  */
1658
1825
  secure() {
1659
1826
  return this.protocol() === "https";
@@ -1674,6 +1841,7 @@ var Request = class extends Macroable5 {
1674
1841
  * ```
1675
1842
  *
1676
1843
  * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
1844
+ * @returns {string | null} Request host or null if not found
1677
1845
  */
1678
1846
  host() {
1679
1847
  let host = this.header("host");
@@ -1701,6 +1869,7 @@ var Request = class extends Macroable5 {
1701
1869
  * ```
1702
1870
  *
1703
1871
  * The value of trustProxy is passed directly to [proxy-addr](https://www.npmjs.com/package/proxy-addr)
1872
+ * @returns {string | null} Request hostname (without port) or null if not found
1704
1873
  */
1705
1874
  hostname() {
1706
1875
  const host = this.host();
@@ -1716,6 +1885,7 @@ var Request = class extends Macroable5 {
1716
1885
  * returned if [[hostname]] is `null` or is an IP address.
1717
1886
  *
1718
1887
  * Also `www` is not considered as a subdomain
1888
+ * @returns {string[]} Array of subdomains (excluding www)
1719
1889
  */
1720
1890
  subdomains() {
1721
1891
  const hostname = this.hostname();
@@ -1732,6 +1902,7 @@ var Request = class extends Macroable5 {
1732
1902
  /**
1733
1903
  * Returns a boolean telling, if request `X-Requested-With === 'xmlhttprequest'`
1734
1904
  * or not.
1905
+ * @returns {boolean} True if request is an AJAX request
1735
1906
  */
1736
1907
  ajax() {
1737
1908
  const xRequestedWith = this.header("X-Requested-With", "");
@@ -1740,6 +1911,7 @@ var Request = class extends Macroable5 {
1740
1911
  /**
1741
1912
  * Returns a boolean telling, if request has `X-Pjax` header
1742
1913
  * set or not
1914
+ * @returns {boolean} True if request is a PJAX request
1743
1915
  */
1744
1916
  pjax() {
1745
1917
  return !!this.header("X-Pjax");
@@ -1754,6 +1926,8 @@ var Request = class extends Macroable5 {
1754
1926
  * // include query string
1755
1927
  * request.url(true)
1756
1928
  * ```
1929
+ * @param includeQueryString - Whether to include query string in the URL
1930
+ * @returns {string} Request pathname, optionally with query string
1757
1931
  */
1758
1932
  url(includeQueryString) {
1759
1933
  const pathname = this.parsedUrl.pathname;
@@ -1770,6 +1944,8 @@ var Request = class extends Macroable5 {
1770
1944
  * // include query string
1771
1945
  * request.completeUrl(true)
1772
1946
  * ```
1947
+ * @param includeQueryString - Whether to include query string in the URL
1948
+ * @returns {string} Complete URL including protocol and host
1773
1949
  */
1774
1950
  completeUrl(includeQueryString) {
1775
1951
  const protocol = this.protocol();
@@ -1778,6 +1954,8 @@ var Request = class extends Macroable5 {
1778
1954
  }
1779
1955
  /**
1780
1956
  * Find if the current HTTP request is for the given route or the routes
1957
+ * @param routeIdentifier - Route name, pattern, or handler reference to match
1958
+ * @returns {boolean} True if the request matches any of the given route identifiers
1781
1959
  */
1782
1960
  matchesRoute(routeIdentifier) {
1783
1961
  if (!this.ctx || !this.ctx.route) {
@@ -1823,6 +2001,8 @@ var Request = class extends Macroable5 {
1823
2001
  * // process XML
1824
2002
  * }
1825
2003
  * ```
2004
+ * @param types - Array of content types to match against
2005
+ * @returns {string | null} Best matching content type or null if no match
1826
2006
  */
1827
2007
  is(types) {
1828
2008
  return typeIs(this.request, types) || null;
@@ -1847,6 +2027,8 @@ var Request = class extends Macroable5 {
1847
2027
  * // decide yourself
1848
2028
  * }
1849
2029
  * ```
2030
+ * @param types - Array of types to match against Accept header
2031
+ * @returns {T | null} Best matching accept type or null if no match
1850
2032
  */
1851
2033
  accepts(types) {
1852
2034
  this.#initiateAccepts();
@@ -1858,6 +2040,7 @@ var Request = class extends Macroable5 {
1858
2040
  *
1859
2041
  * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
1860
2042
  * docs too.
2043
+ * @returns {string[]} Array of accepted types in preference order
1861
2044
  */
1862
2045
  types() {
1863
2046
  this.#initiateAccepts();
@@ -1883,6 +2066,8 @@ var Request = class extends Macroable5 {
1883
2066
  * return view.render('about', { lang: 'en' })
1884
2067
  * }
1885
2068
  * ```
2069
+ * @param languages - Array of languages to match against Accept-Language header
2070
+ * @returns {T | null} Best matching language or null if no match
1886
2071
  */
1887
2072
  language(languages) {
1888
2073
  this.#initiateAccepts();
@@ -1894,6 +2079,7 @@ var Request = class extends Macroable5 {
1894
2079
  *
1895
2080
  * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
1896
2081
  * docs too.
2082
+ * @returns {string[]} Array of accepted languages in preference order
1897
2083
  */
1898
2084
  languages() {
1899
2085
  this.#initiateAccepts();
@@ -1917,6 +2103,8 @@ var Request = class extends Macroable5 {
1917
2103
  * // make ISO-8859-1 friendly response
1918
2104
  * }
1919
2105
  * ```
2106
+ * @param charsets - Array of charsets to match against Accept-Charset header
2107
+ * @returns {T | null} Best matching charset or null if no match
1920
2108
  */
1921
2109
  charset(charsets) {
1922
2110
  this.#initiateAccepts();
@@ -1928,6 +2116,7 @@ var Request = class extends Macroable5 {
1928
2116
  *
1929
2117
  * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
1930
2118
  * docs too.
2119
+ * @returns {string[]} Array of accepted charsets in preference order
1931
2120
  */
1932
2121
  charsets() {
1933
2122
  this.#initiateAccepts();
@@ -1941,17 +2130,20 @@ var Request = class extends Macroable5 {
1941
2130
  *
1942
2131
  * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
1943
2132
  * docs too.
2133
+ * @param encodings - Array of encodings to match against Accept-Encoding header
2134
+ * @returns {T | null} Best matching encoding or null if no match
1944
2135
  */
1945
2136
  encoding(encodings) {
1946
2137
  this.#initiateAccepts();
1947
2138
  return this.#lazyAccepts.encoding(encodings) || null;
1948
2139
  }
1949
2140
  /**
1950
- * Return the charsets that the request accepts, in the order of the
2141
+ * Return the encodings that the request accepts, in the order of the
1951
2142
  * client's preference (most preferred first).
1952
2143
  *
1953
2144
  * Make sure to check [accepts](https://www.npmjs.com/package/accepts) package
1954
2145
  * docs too.
2146
+ * @returns {string[]} Array of accepted encodings in preference order
1955
2147
  */
1956
2148
  encodings() {
1957
2149
  this.#initiateAccepts();
@@ -1959,6 +2151,7 @@ var Request = class extends Macroable5 {
1959
2151
  }
1960
2152
  /**
1961
2153
  * Returns a boolean telling if request has body
2154
+ * @returns {boolean} True if request contains a body
1962
2155
  */
1963
2156
  hasBody() {
1964
2157
  return typeIs.hasBody(this.request);
@@ -1986,6 +2179,7 @@ var Request = class extends Macroable5 {
1986
2179
  * response.send(responseBody)
1987
2180
  * }
1988
2181
  * ```
2182
+ * @returns {boolean} True if client cache is fresh (should return 304)
1989
2183
  */
1990
2184
  fresh() {
1991
2185
  if (["GET", "HEAD"].indexOf(this.intended()) === -1) {
@@ -1999,6 +2193,7 @@ var Request = class extends Macroable5 {
1999
2193
  }
2000
2194
  /**
2001
2195
  * Opposite of [[fresh]]
2196
+ * @returns {boolean} True if client cache is stale (should send new response)
2002
2197
  */
2003
2198
  stale() {
2004
2199
  return !this.fresh();
@@ -2006,6 +2201,7 @@ var Request = class extends Macroable5 {
2006
2201
  /**
2007
2202
  * Returns all parsed and signed cookies. Signed cookies ensures
2008
2203
  * that their value isn't tampered.
2204
+ * @returns {{ [key: string]: any }} Object containing all parsed cookies
2009
2205
  */
2010
2206
  cookiesList() {
2011
2207
  this.#initiateCookieParser();
@@ -2014,14 +2210,20 @@ var Request = class extends Macroable5 {
2014
2210
  /**
2015
2211
  * Returns value for a given key from signed cookies. Optional
2016
2212
  * defaultValue is returned when actual value is undefined.
2213
+ * @param key - Cookie name to lookup
2214
+ * @param defaultValue - Default value when cookie is not found
2215
+ * @returns Cookie value or default value if not found
2017
2216
  */
2018
2217
  cookie(key, defaultValue) {
2019
2218
  this.#initiateCookieParser();
2020
2219
  return this.#cookieParser.unsign(key) || defaultValue;
2021
2220
  }
2022
2221
  /**
2023
- * Returns value for a given key from signed cookies. Optional
2222
+ * Returns value for a given key from encrypted cookies. Optional
2024
2223
  * defaultValue is returned when actual value is undefined.
2224
+ * @param key - Cookie name to lookup
2225
+ * @param defaultValue - Default value when cookie is not found
2226
+ * @returns Decrypted cookie value or default value if not found
2025
2227
  */
2026
2228
  encryptedCookie(key, defaultValue) {
2027
2229
  this.#initiateCookieParser();
@@ -2035,8 +2237,10 @@ var Request = class extends Macroable5 {
2035
2237
  return this.#cookieParser.decode(key, encoded) || defaultValueOrOptions;
2036
2238
  }
2037
2239
  /**
2038
- * Returns a boolean telling if a signed url as a valid signature
2240
+ * Returns a boolean telling if a signed url has a valid signature
2039
2241
  * or not.
2242
+ * @param purpose - Optional purpose for signature verification
2243
+ * @returns {boolean} True if the signed URL has a valid signature
2040
2244
  */
2041
2245
  hasValidSignature(purpose) {
2042
2246
  const { signature, ...rest } = this.qs();
@@ -2052,6 +2256,7 @@ var Request = class extends Macroable5 {
2052
2256
  }
2053
2257
  /**
2054
2258
  * Serializes request to JSON format
2259
+ * @returns Object representation of the request
2055
2260
  */
2056
2261
  serialize() {
2057
2262
  return {
@@ -2071,6 +2276,7 @@ var Request = class extends Macroable5 {
2071
2276
  }
2072
2277
  /**
2073
2278
  * toJSON copy of the request
2279
+ * @returns JSON representation of the request
2074
2280
  */
2075
2281
  toJSON() {
2076
2282
  return this.serialize();
@@ -2081,21 +2287,40 @@ var Request = class extends Macroable5 {
2081
2287
  import { parse } from "url";
2082
2288
  var Redirect = class {
2083
2289
  /**
2084
- * A boolean to forward the existing query string
2290
+ * Flag indicating whether to forward the existing query string from the current request
2085
2291
  */
2086
2292
  #forwardQueryString = false;
2087
2293
  /**
2088
- * The status code for the redirect
2294
+ * HTTP status code to use for the redirect response (defaults to 302)
2089
2295
  */
2090
2296
  #statusCode = 302;
2091
2297
  /**
2092
- * A custom query string to forward
2298
+ * Custom query string parameters to include in the redirect URL
2093
2299
  */
2094
2300
  #queryString = {};
2301
+ /**
2302
+ * Reference to the Node.js incoming HTTP request
2303
+ */
2095
2304
  #request;
2305
+ /**
2306
+ * Reference to the AdonisJS response instance
2307
+ */
2096
2308
  #response;
2309
+ /**
2310
+ * Reference to the AdonisJS router instance for URL building
2311
+ */
2097
2312
  #router;
2313
+ /**
2314
+ * Query string parser instance
2315
+ */
2098
2316
  #qs;
2317
+ /**
2318
+ * Creates a new Redirect instance for handling HTTP redirects
2319
+ * @param request - Node.js incoming HTTP request
2320
+ * @param response - AdonisJS response instance
2321
+ * @param router - AdonisJS router instance
2322
+ * @param qs - Query string parser instance
2323
+ */
2099
2324
  constructor(request, response, router, qs) {
2100
2325
  this.#request = request;
2101
2326
  this.#response = response;
@@ -2103,7 +2328,9 @@ var Redirect = class {
2103
2328
  this.#qs = qs;
2104
2329
  }
2105
2330
  /**
2106
- * Sends response by setting require headers
2331
+ * Sends the redirect response by setting required headers and status code
2332
+ * @param url - Target URL for redirection
2333
+ * @param query - Query string parameters to append
2107
2334
  */
2108
2335
  #sendResponse(url, query) {
2109
2336
  const stringified = this.#qs.stringify(query);
@@ -2115,22 +2342,25 @@ var Redirect = class {
2115
2342
  this.#response.send(`Redirecting to ${url}`);
2116
2343
  }
2117
2344
  /**
2118
- * Returns the referrer url
2345
+ * Extracts and returns the referrer URL from request headers
2346
+ * @returns {string} The referrer URL or '/' if not found
2119
2347
  */
2120
2348
  #getReferrerUrl() {
2121
2349
  let url = this.#request.headers["referer"] || this.#request.headers["referrer"] || "/";
2122
2350
  return Array.isArray(url) ? url[0] : url;
2123
2351
  }
2124
2352
  /**
2125
- * Set a custom status code.
2353
+ * Sets a custom HTTP status code for the redirect response
2354
+ * @param statusCode - HTTP status code to use (e.g., 301, 302, 307)
2355
+ * @returns {this} The Redirect instance for method chaining
2126
2356
  */
2127
2357
  status(statusCode) {
2128
2358
  this.#statusCode = statusCode;
2129
2359
  return this;
2130
2360
  }
2131
2361
  /**
2132
- * Clearing query string values added using the
2133
- * "withQs" method
2362
+ * Clears any query string values previously added using the withQs method
2363
+ * @returns {this} The Redirect instance for method chaining
2134
2364
  */
2135
2365
  clearQs() {
2136
2366
  this.#forwardQueryString = false;
@@ -2150,7 +2380,8 @@ var Redirect = class {
2150
2380
  return this;
2151
2381
  }
2152
2382
  /**
2153
- * Redirect to the previous path.
2383
+ * Redirects to the previous path using the Referer header
2384
+ * Falls back to '/' if no referrer is found
2154
2385
  */
2155
2386
  back() {
2156
2387
  let query = {};
@@ -2165,7 +2396,8 @@ var Redirect = class {
2165
2396
  this.#sendResponse(url.pathname || "", query);
2166
2397
  }
2167
2398
  /**
2168
- * Redirect the request using a route identifier.
2399
+ * Redirects to a route using its identifier (name, pattern, or handler reference)
2400
+ * @param args - Route identifier, parameters, and options for URL building
2169
2401
  */
2170
2402
  toRoute(...args) {
2171
2403
  const [identifier, params, options] = args;
@@ -2177,7 +2409,8 @@ var Redirect = class {
2177
2409
  return this.toPath(url);
2178
2410
  }
2179
2411
  /**
2180
- * Redirect the request using a path.
2412
+ * Redirects to a specific URL path
2413
+ * @param url - Target URL path for redirection
2181
2414
  */
2182
2415
  toPath(url) {
2183
2416
  let query = {};
@@ -2255,24 +2488,17 @@ var ResponseStatus = {
2255
2488
  NetworkAuthenticationRequired: 511
2256
2489
  };
2257
2490
 
2258
- // src/response.ts
2259
- import etag from "etag";
2260
- import vary from "vary";
2261
- import fresh2 from "fresh";
2262
- import destroy from "destroy";
2263
- import { extname } from "path";
2264
- import { Buffer } from "buffer";
2265
- import onFinished from "on-finished";
2266
- import { stat } from "fs/promises";
2267
- import Macroable6 from "@poppinss/macroable";
2268
- import { createReadStream } from "fs";
2269
- import contentDisposition from "content-disposition";
2270
- import { safeStringify } from "@poppinss/utils/json";
2271
- import { RuntimeException as RuntimeException3 } from "@poppinss/utils/exception";
2272
-
2273
2491
  // src/cookies/serializer.ts
2274
2492
  var CookieSerializer = class {
2493
+ /**
2494
+ * Cookie client instance for handling cookie operations
2495
+ */
2275
2496
  #client;
2497
+ /**
2498
+ * Create a new instance of CookieSerializer
2499
+ *
2500
+ * @param encryption - The encryption instance for cookie operations
2501
+ */
2276
2502
  constructor(encryption) {
2277
2503
  this.#client = new CookieClient(encryption);
2278
2504
  }
@@ -2286,6 +2512,11 @@ var CookieSerializer = class {
2286
2512
  * serializer.encode('name', 'virk')
2287
2513
  * serializer.encode('name', 'virk', { stringify: false })
2288
2514
  * ```
2515
+ *
2516
+ * @param key - The cookie key
2517
+ * @param value - The value to encode
2518
+ * @param options - Cookie encoding options
2519
+ * @returns The serialized cookie string or null if encoding fails
2289
2520
  */
2290
2521
  encode(key, value, options) {
2291
2522
  const stringify2 = options?.stringify ?? options?.encode;
@@ -2298,6 +2529,11 @@ var CookieSerializer = class {
2298
2529
  /**
2299
2530
  * Sign a key-value pair to a signed cookie. The signed value has a
2300
2531
  * verification hash attached to it to detect data tampering.
2532
+ *
2533
+ * @param key - The cookie key
2534
+ * @param value - The value to sign
2535
+ * @param options - Cookie options
2536
+ * @returns The serialized signed cookie string or null if signing fails
2301
2537
  */
2302
2538
  sign(key, value, options) {
2303
2539
  const packedValue = this.#client.sign(key, value);
@@ -2308,6 +2544,11 @@ var CookieSerializer = class {
2308
2544
  }
2309
2545
  /**
2310
2546
  * Encrypts a key-value pair to an encrypted cookie.
2547
+ *
2548
+ * @param key - The cookie key
2549
+ * @param value - The value to encrypt
2550
+ * @param options - Cookie options
2551
+ * @returns The serialized encrypted cookie string or null if encryption fails
2311
2552
  */
2312
2553
  encrypt(key, value, options) {
2313
2554
  const packedValue = this.#client.encrypt(key, value);
@@ -2319,8 +2560,31 @@ var CookieSerializer = class {
2319
2560
  };
2320
2561
 
2321
2562
  // src/response.ts
2563
+ import etag from "etag";
2564
+ import vary from "vary";
2565
+ import fresh2 from "fresh";
2566
+ import destroy from "destroy";
2567
+ import { extname } from "path";
2568
+ import { Buffer } from "buffer";
2569
+ import onFinished from "on-finished";
2570
+ import { stat } from "fs/promises";
2571
+ import Macroable6 from "@poppinss/macroable";
2572
+ import { createReadStream } from "fs";
2573
+ import contentDisposition from "content-disposition";
2574
+ import { safeStringify } from "@poppinss/utils/json";
2575
+ import { RuntimeException as RuntimeException3 } from "@poppinss/utils/exception";
2322
2576
  var CACHEABLE_HTTP_METHODS = ["GET", "HEAD"];
2323
2577
  var Response = class extends Macroable6 {
2578
+ /**
2579
+ * Creates a new Response instance
2580
+ *
2581
+ * @param request - Node.js IncomingMessage instance
2582
+ * @param response - Node.js ServerResponse instance
2583
+ * @param encryption - Encryption service for cookie handling
2584
+ * @param config - Response configuration settings
2585
+ * @param router - Router instance for URL generation
2586
+ * @param qs - Query string parser
2587
+ */
2324
2588
  constructor(request, response, encryption, config, router, qs) {
2325
2589
  super();
2326
2590
  this.request = request;
@@ -2331,73 +2595,67 @@ var Response = class extends Macroable6 {
2331
2595
  this.#cookieSerializer = new CookieSerializer(encryption);
2332
2596
  }
2333
2597
  /**
2334
- * Query string parser
2598
+ * Query string parser instance used for URL manipulation
2335
2599
  */
2336
2600
  #qs;
2337
2601
  /**
2338
- * Outgoing headers
2602
+ * Collection of outgoing HTTP headers to be sent with the response
2339
2603
  */
2340
2604
  #headers = {};
2341
2605
  /**
2342
- * Has explicit status been set
2606
+ * Flag indicating whether an explicit status code has been set
2343
2607
  */
2344
2608
  #hasExplicitStatus = false;
2345
2609
  /**
2346
- * Cookies serializer to serialize the outgoing cookies
2610
+ * Cookie serializer instance for handling cookie encryption, signing, and encoding
2347
2611
  */
2348
2612
  #cookieSerializer;
2349
2613
  /**
2350
- * Router is used to make the redirect URLs from routes
2614
+ * Router instance used for generating redirect URLs from route definitions
2351
2615
  */
2352
2616
  #router;
2353
2617
  /**
2354
- * Response config
2618
+ * Configuration object containing response-related settings
2355
2619
  */
2356
2620
  #config;
2357
2621
  /**
2358
- * Does response has body set that will written to the
2359
- * response socket at the end of the request
2622
+ * Indicates whether the response has any content (body, stream, or file) ready to be sent
2360
2623
  */
2361
2624
  get hasLazyBody() {
2362
2625
  return !!(this.lazyBody.content || this.lazyBody.fileToStream || this.lazyBody.stream);
2363
2626
  }
2364
2627
  /**
2365
- * Find if the response has non-stream content
2628
+ * Indicates whether the response has non-stream content set
2366
2629
  */
2367
2630
  get hasContent() {
2368
2631
  return !!this.lazyBody.content;
2369
2632
  }
2370
2633
  /**
2371
- * Returns true when response body is set using "response.stream"
2372
- * method
2634
+ * Indicates whether the response body is set as a readable stream
2373
2635
  */
2374
2636
  get hasStream() {
2375
2637
  return !!this.lazyBody.stream;
2376
2638
  }
2377
2639
  /**
2378
- * Returns true when response body is set using "response.download"
2379
- * or "response.attachment" methods
2640
+ * Indicates whether the response is configured to stream a file
2380
2641
  */
2381
2642
  get hasFileToStream() {
2382
2643
  return !!this.lazyBody.fileToStream;
2383
2644
  }
2384
2645
  /**
2385
- * Returns the response content. Check if the response
2386
- * has content using the "hasContent" method
2646
+ * The response content data
2387
2647
  */
2388
2648
  get content() {
2389
2649
  return this.lazyBody.content;
2390
2650
  }
2391
2651
  /**
2392
- * Returns reference to the stream set using "response.stream"
2393
- * method
2652
+ * The readable stream instance configured for the response
2394
2653
  */
2395
2654
  get outgoingStream() {
2396
2655
  return this.lazyBody.stream?.[0];
2397
2656
  }
2398
2657
  /**
2399
- * Returns reference to the file path set using "response.stream"
2400
- * method.
2658
+ * Configuration for file streaming including path and etag generation flag
2401
2659
  */
2402
2660
  get fileToStream() {
2403
2661
  return this.lazyBody.fileToStream ? {
@@ -2406,48 +2664,46 @@ var Response = class extends Macroable6 {
2406
2664
  } : void 0;
2407
2665
  }
2408
2666
  /**
2409
- * Lazy body is used to set the response body. However, do not
2410
- * write it on the socket immediately unless `response.finish`
2411
- * is called.
2667
+ * Lazy body container that holds response content until ready to send.
2668
+ * Contains different types of response data: content, stream, or fileToStream.
2412
2669
  */
2413
2670
  lazyBody = {};
2414
2671
  /**
2415
- * The ctx will be set by the context itself. It creates a circular
2416
- * reference
2672
+ * HTTP context reference (creates circular dependency with HttpContext)
2417
2673
  */
2418
2674
  ctx;
2419
2675
  /**
2420
- * Returns a boolean telling if response is finished or not.
2421
- * Any more attempts to update headers or body will result
2422
- * in raised exceptions.
2676
+ * Indicates whether the response has been completely sent
2423
2677
  */
2424
2678
  get finished() {
2425
2679
  return this.response.writableFinished;
2426
2680
  }
2427
2681
  /**
2428
- * Returns a boolean telling if response headers has been sent or not.
2429
- * Any more attempts to update headers will result in raised
2430
- * exceptions.
2682
+ * Indicates whether response headers have been sent to the client
2431
2683
  */
2432
2684
  get headersSent() {
2433
2685
  return this.response.headersSent;
2434
2686
  }
2435
2687
  /**
2436
- * Returns a boolean telling if response headers and body is written
2437
- * or not. When value is `true`, you can feel free to write headers
2438
- * and body.
2688
+ * Indicates whether the response is still pending (headers and body can still be modified)
2439
2689
  */
2440
2690
  get isPending() {
2441
2691
  return !this.headersSent && !this.finished;
2442
2692
  }
2443
2693
  /**
2444
- * Normalizes header value to a string or an array of string
2694
+ * Normalizes header value to a string or an array of strings
2695
+ *
2696
+ * @param value - The header value to normalize
2697
+ * @returns Normalized header value
2445
2698
  */
2446
2699
  #castHeaderValue(value) {
2447
2700
  return Array.isArray(value) ? value.map(String) : String(value);
2448
2701
  }
2449
2702
  /**
2450
2703
  * Ends the response by flushing headers and writing body
2704
+ *
2705
+ * @param body - Optional response body
2706
+ * @param statusCode - Optional status code
2451
2707
  */
2452
2708
  #endResponse(body, statusCode) {
2453
2709
  this.writeHead(statusCode);
@@ -2455,14 +2711,18 @@ var Response = class extends Macroable6 {
2455
2711
  res.end(body, null, null);
2456
2712
  }
2457
2713
  /**
2458
- * Returns type for the content body. Only following types are allowed
2714
+ * Determines the data type of the content for serialization
2459
2715
  *
2716
+ * Supported types:
2460
2717
  * - Dates
2461
2718
  * - Arrays
2462
2719
  * - Booleans
2463
2720
  * - Objects
2464
2721
  * - Strings
2465
2722
  * - Buffer
2723
+ *
2724
+ * @param content - The content to analyze
2725
+ * @returns The determined data type as string
2466
2726
  */
2467
2727
  #getDataType(content) {
2468
2728
  const dataType = typeof content;
@@ -2484,10 +2744,17 @@ var Response = class extends Macroable6 {
2484
2744
  throw new RuntimeException3(`Cannot serialize "${dataType}" to HTTP response`);
2485
2745
  }
2486
2746
  /**
2487
- * Writes the body with appropriate response headers. Etag header is set
2488
- * when `generateEtag` is set to `true`.
2747
+ * Writes the response body with appropriate headers and content type detection
2489
2748
  *
2490
- * Empty body results in `204`.
2749
+ * Automatically sets:
2750
+ * - Content-Type based on content analysis
2751
+ * - Content-Length header
2752
+ * - ETag header (if enabled)
2753
+ * - Status code 204 for empty bodies
2754
+ *
2755
+ * @param content - The response content
2756
+ * @param generateEtag - Whether to generate ETag header
2757
+ * @param jsonpCallbackName - Optional JSONP callback name
2491
2758
  */
2492
2759
  writeBody(content, generateEtag, jsonpCallbackName) {
2493
2760
  const hasEmptyBody = content === null || content === void 0 || content === "";
@@ -2557,7 +2824,16 @@ var Response = class extends Macroable6 {
2557
2824
  this.#endResponse(content);
2558
2825
  }
2559
2826
  /**
2560
- * Stream the body to the response and handles cleaning up the stream
2827
+ * Streams the response body and handles error cleanup
2828
+ *
2829
+ * Manages stream lifecycle including:
2830
+ * - Error handling with custom callbacks
2831
+ * - Proper stream cleanup to prevent memory leaks
2832
+ * - Response finalization
2833
+ *
2834
+ * @param body - The readable stream to pipe
2835
+ * @param errorCallback - Optional custom error handler
2836
+ * @returns Promise that resolves when streaming is complete
2561
2837
  */
2562
2838
  streamBody(body, errorCallback) {
2563
2839
  return new Promise((resolve) => {
@@ -2598,7 +2874,19 @@ var Response = class extends Macroable6 {
2598
2874
  });
2599
2875
  }
2600
2876
  /**
2601
- * Downloads a file by streaming it to the response
2877
+ * Streams a file for download with proper headers and caching support
2878
+ *
2879
+ * Sets appropriate headers:
2880
+ * - Last-Modified based on file stats
2881
+ * - Content-Type based on file extension
2882
+ * - Content-Length from file size
2883
+ * - ETag (if enabled)
2884
+ *
2885
+ * Handles HEAD requests and cache validation (304 responses).
2886
+ *
2887
+ * @param filePath - Path to the file to stream
2888
+ * @param generateEtag - Whether to generate ETag header
2889
+ * @param errorCallback - Optional custom error handler
2602
2890
  */
2603
2891
  async streamFileForDownload(filePath, generateEtag, errorCallback) {
2604
2892
  try {
@@ -2638,18 +2926,18 @@ var Response = class extends Macroable6 {
2638
2926
  }
2639
2927
  }
2640
2928
  /**
2641
- * Listen for the event the response is written
2642
- * to the TCP socket.
2929
+ * Registers a callback to be called when the response is finished
2930
+ *
2931
+ * The callback is executed when the response has been completely sent.
2932
+ * Uses the "on-finished" package internally.
2643
2933
  *
2644
- * Under the hood the callback is registered with
2645
- * the "https://github.com/jshttp/on-finished" package
2934
+ * @param callback - Function to call when response is finished
2646
2935
  */
2647
2936
  onFinish(callback) {
2648
2937
  onFinished(this.response, callback);
2649
2938
  }
2650
2939
  /**
2651
- * Writes headers with the Node.js res object using the
2652
- * response.setHeader method
2940
+ * Transfers all buffered headers to the underlying Node.js response object
2653
2941
  */
2654
2942
  relayHeaders() {
2655
2943
  if (!this.headersSent) {
@@ -2662,22 +2950,29 @@ var Response = class extends Macroable6 {
2662
2950
  }
2663
2951
  }
2664
2952
  /**
2665
- * Calls res.writeHead on the Node.js res object.
2953
+ * Writes the response status code and headers
2954
+ *
2955
+ * @param statusCode - Optional status code to set
2956
+ * @returns The Response instance for chaining
2666
2957
  */
2667
2958
  writeHead(statusCode) {
2668
2959
  this.response.writeHead(statusCode || this.response.statusCode, this.#headers);
2669
2960
  return this;
2670
2961
  }
2671
2962
  /**
2672
- * Returns the existing value for a given HTTP response
2673
- * header.
2963
+ * Gets the value of a response header
2964
+ *
2965
+ * @param key - Header name
2966
+ * @returns The header value
2674
2967
  */
2675
2968
  getHeader(key) {
2676
2969
  const value = this.#headers[key.toLowerCase()];
2677
2970
  return value === void 0 ? this.response.getHeader(key) : value;
2678
2971
  }
2679
2972
  /**
2680
- * Get response headers
2973
+ * Gets all response headers as an object
2974
+ *
2975
+ * @returns Object containing all headers
2681
2976
  */
2682
2977
  getHeaders() {
2683
2978
  return {
@@ -2686,14 +2981,15 @@ var Response = class extends Macroable6 {
2686
2981
  };
2687
2982
  }
2688
2983
  /**
2689
- * Set header on the response. To `append` values to the existing header, we suggest
2690
- * using [[append]] method.
2984
+ * Sets a response header (replaces existing value)
2691
2985
  *
2692
- * If `value` is non existy, then header won't be set.
2986
+ * @param key - Header name
2987
+ * @param value - Header value (ignored if null/undefined)
2988
+ * @returns The Response instance for chaining
2693
2989
  *
2694
2990
  * @example
2695
- * ```js
2696
- * response.header('content-type', 'application/json')
2991
+ * ```ts
2992
+ * response.header('Content-Type', 'application/json')
2697
2993
  * ```
2698
2994
  */
2699
2995
  header(key, value) {
@@ -2704,14 +3000,15 @@ var Response = class extends Macroable6 {
2704
3000
  return this;
2705
3001
  }
2706
3002
  /**
2707
- * Append value to an existing header. To replace the value, we suggest using
2708
- * [[header]] method.
3003
+ * Appends a value to an existing response header
2709
3004
  *
2710
- * If `value` is not existy, then header won't be set.
3005
+ * @param key - Header name
3006
+ * @param value - Header value to append (ignored if null/undefined)
3007
+ * @returns The Response instance for chaining
2711
3008
  *
2712
3009
  * @example
2713
- * ```js
2714
- * response.append('set-cookie', 'username=virk')
3010
+ * ```ts
3011
+ * response.append('Set-Cookie', 'session=abc123')
2715
3012
  * ```
2716
3013
  */
2717
3014
  append(key, value) {
@@ -2731,7 +3028,11 @@ var Response = class extends Macroable6 {
2731
3028
  return this;
2732
3029
  }
2733
3030
  /**
2734
- * Adds HTTP response header, when it doesn't exists already.
3031
+ * Sets a header only if it doesn't already exist
3032
+ *
3033
+ * @param key - Header name
3034
+ * @param value - Header value
3035
+ * @returns The Response instance for chaining
2735
3036
  */
2736
3037
  safeHeader(key, value) {
2737
3038
  if (!this.getHeader(key)) {
@@ -2740,7 +3041,10 @@ var Response = class extends Macroable6 {
2740
3041
  return this;
2741
3042
  }
2742
3043
  /**
2743
- * Removes the existing response header from being sent.
3044
+ * Removes a response header
3045
+ *
3046
+ * @param key - Header name to remove
3047
+ * @returns The Response instance for chaining
2744
3048
  */
2745
3049
  removeHeader(key) {
2746
3050
  key = key.toLowerCase();
@@ -2751,13 +3055,18 @@ var Response = class extends Macroable6 {
2751
3055
  return this;
2752
3056
  }
2753
3057
  /**
2754
- * Returns the status code for the response
3058
+ * Gets the current response status code
3059
+ *
3060
+ * @returns The HTTP status code
2755
3061
  */
2756
3062
  getStatus() {
2757
3063
  return this.response.statusCode;
2758
3064
  }
2759
3065
  /**
2760
- * Set HTTP status code
3066
+ * Sets the response status code
3067
+ *
3068
+ * @param code - HTTP status code
3069
+ * @returns The Response instance for chaining
2761
3070
  */
2762
3071
  status(code) {
2763
3072
  this.#hasExplicitStatus = true;
@@ -2765,8 +3074,10 @@ var Response = class extends Macroable6 {
2765
3074
  return this;
2766
3075
  }
2767
3076
  /**
2768
- * Set's status code only when it's not explictly
2769
- * set
3077
+ * Sets the status code only if not explicitly set already
3078
+ *
3079
+ * @param code - HTTP status code
3080
+ * @returns The Response instance for chaining
2770
3081
  */
2771
3082
  safeStatus(code) {
2772
3083
  if (this.#hasExplicitStatus) {
@@ -2776,15 +3087,16 @@ var Response = class extends Macroable6 {
2776
3087
  return this;
2777
3088
  }
2778
3089
  /**
2779
- * Set response type by looking up for the mime-type using
2780
- * partial types like file extensions.
3090
+ * Sets the Content-Type header based on mime type lookup
2781
3091
  *
2782
- * Make sure to read [mime-types](https://www.npmjs.com/package/mime-types) docs
2783
- * too.
3092
+ * @param type - File extension or mime type
3093
+ * @param charset - Optional character encoding
3094
+ * @returns The Response instance for chaining
2784
3095
  *
2785
3096
  * @example
2786
- * ```js
2787
- * response.type('.json') // Content-type: application/json
3097
+ * ```ts
3098
+ * response.type('.json') // Content-Type: application/json
3099
+ * response.type('html', 'utf-8') // Content-Type: text/html; charset=utf-8
2788
3100
  * ```
2789
3101
  */
2790
3102
  type(type, charset) {
@@ -2793,25 +3105,30 @@ var Response = class extends Macroable6 {
2793
3105
  return this;
2794
3106
  }
2795
3107
  /**
2796
- * Set the Vary HTTP header
3108
+ * Sets the Vary HTTP header for cache control
3109
+ *
3110
+ * @param field - Header field name(s) to vary on
3111
+ * @returns The Response instance for chaining
2797
3112
  */
2798
3113
  vary(field) {
2799
3114
  vary(this.response, field);
2800
3115
  return this;
2801
3116
  }
2802
3117
  /**
2803
- * Set etag by computing hash from the body. This class will set the etag automatically
2804
- * when `etag = true` in the defined config object.
3118
+ * Sets the ETag header by computing a hash from the response body
2805
3119
  *
2806
- * Use this function, when you want to compute etag manually for some other resons.
3120
+ * @param body - The response body to hash
3121
+ * @param weak - Whether to generate a weak ETag
3122
+ * @returns The Response instance for chaining
2807
3123
  */
2808
3124
  setEtag(body, weak = false) {
2809
3125
  this.header("Etag", etag(body, { weak }));
2810
3126
  return this;
2811
3127
  }
2812
3128
  /**
2813
- * Set X-Request-Id header by copying the header value from the request if it exists.
3129
+ * Sets the X-Request-Id header by copying from the incoming request
2814
3130
  *
3131
+ * @returns The Response instance for chaining
2815
3132
  */
2816
3133
  setRequestId() {
2817
3134
  const requestId = this.request.headers["x-request-id"];
@@ -2821,27 +3138,20 @@ var Response = class extends Macroable6 {
2821
3138
  return this;
2822
3139
  }
2823
3140
  /**
2824
- * Returns a boolean telling if the new response etag evaluates same
2825
- * as the request header `if-none-match`. In case of `true`, the
2826
- * server must return `304` response, telling the browser to
2827
- * use the client cache.
3141
+ * Checks if the response is fresh (client cache is valid)
2828
3142
  *
2829
- * You won't have to deal with this method directly, since AdonisJs will
2830
- * handle this for you when `http.etag = true` inside `config/app.js` file.
3143
+ * Compares ETags and modified dates between request and response
3144
+ * to determine if a 304 Not Modified response should be sent.
2831
3145
  *
2832
- * However, this is how you can use it manually.
3146
+ * @returns True if client cache is fresh, false otherwise
2833
3147
  *
2834
3148
  * @example
2835
- * ```js
2836
- * const responseBody = view.render('some-view')
2837
- *
2838
- * // sets the HTTP etag header for response
2839
- * response.setEtag(responseBody)
2840
- *
3149
+ * ```ts
3150
+ * response.setEtag(content)
2841
3151
  * if (response.fresh()) {
2842
- * response.sendStatus(304)
3152
+ * response.status(304).send(null)
2843
3153
  * } else {
2844
- * response.send(responseBody)
3154
+ * response.send(content)
2845
3155
  * }
2846
3156
  * ```
2847
3157
  */
@@ -2856,8 +3166,9 @@ var Response = class extends Macroable6 {
2856
3166
  return false;
2857
3167
  }
2858
3168
  /**
2859
- * Returns the response body. Returns null when response
2860
- * body is a stream
3169
+ * Gets the response body content
3170
+ *
3171
+ * @returns The response body or null if not set or is a stream
2861
3172
  */
2862
3173
  getBody() {
2863
3174
  if (this.lazyBody.content) {
@@ -2866,58 +3177,54 @@ var Response = class extends Macroable6 {
2866
3177
  return null;
2867
3178
  }
2868
3179
  /**
2869
- * Send the body as response and optionally generate etag. The default value
2870
- * is read from `config/app.js` file, using `http.etag` property.
3180
+ * Sends the response body with optional ETag generation
2871
3181
  *
2872
- * This method buffers the body if `explicitEnd = true`, which is the default
2873
- * behavior and do not change, unless you know what you are doing.
3182
+ * @param body - The response body
3183
+ * @param generateEtag - Whether to generate ETag header (defaults to config)
2874
3184
  */
2875
3185
  send(body, generateEtag = this.#config.etag) {
2876
3186
  this.lazyBody.content = [body, generateEtag];
2877
3187
  }
2878
3188
  /**
2879
- * Alias of [[send]]
3189
+ * Sends a JSON response (alias for send)
3190
+ *
3191
+ * @param body - The response body to serialize as JSON
3192
+ * @param generateEtag - Whether to generate ETag header
2880
3193
  */
2881
3194
  json(body, generateEtag = this.#config.etag) {
2882
3195
  return this.send(body, generateEtag);
2883
3196
  }
2884
3197
  /**
2885
- * Writes response as JSONP. The callback name is resolved as follows, with priority
2886
- * from top to bottom.
3198
+ * Sends a JSONP response with callback wrapping
2887
3199
  *
2888
- * 1. Explicitly defined as 2nd Param.
2889
- * 2. Fetch from request query string.
2890
- * 3. Use the config value `http.jsonpCallbackName` from `config/app.js`.
2891
- * 4. Fallback to `callback`.
3200
+ * Callback name resolution priority:
3201
+ * 1. Explicit callbackName parameter
3202
+ * 2. Query string parameter
3203
+ * 3. Config value
3204
+ * 4. Default "callback"
2892
3205
  *
2893
- * This method buffers the body if `explicitEnd = true`, which is the default
2894
- * behavior and do not change, unless you know what you are doing.
3206
+ * @param body - The response body
3207
+ * @param callbackName - JSONP callback function name
3208
+ * @param generateEtag - Whether to generate ETag header
2895
3209
  */
2896
3210
  jsonp(body, callbackName = this.#config.jsonpCallbackName, generateEtag = this.#config.etag) {
2897
3211
  this.lazyBody.content = [body, generateEtag, callbackName];
2898
3212
  }
2899
3213
  /**
2900
- * Pipe stream to the response. This method will gracefully destroy
2901
- * the stream, avoiding memory leaks.
2902
- *
2903
- * If `raiseErrors=false`, then this method will self handle all the exceptions by
2904
- * writing a generic HTTP response. To have more control over the error, it is
2905
- * recommended to set `raiseErrors=true` and wrap this function inside a
2906
- * `try/catch` statement.
3214
+ * Pipes a readable stream to the response with graceful error handling
2907
3215
  *
2908
- * Streaming a file from the disk and showing 404 when file is missing.
3216
+ * @param body - The readable stream to pipe
3217
+ * @param errorCallback - Optional custom error handler
2909
3218
  *
2910
3219
  * @example
2911
- * ```js
2912
- * // Errors handled automatically with generic HTTP response
3220
+ * ```ts
3221
+ * // Auto error handling
2913
3222
  * response.stream(fs.createReadStream('file.txt'))
2914
3223
  *
2915
- * // Manually handle (note the await call)
2916
- * try {
2917
- * await response.stream(fs.createReadStream('file.txt'))
2918
- * } catch () {
2919
- * response.status(404).send('File not found')
2920
- * }
3224
+ * // Custom error handling
3225
+ * response.stream(stream, (error) => {
3226
+ * return error.code === 'ENOENT' ? ['Not found', 404] : ['Error', 500]
3227
+ * })
2921
3228
  * ```
2922
3229
  */
2923
3230
  stream(body, errorCallback) {
@@ -2927,38 +3234,35 @@ var Response = class extends Macroable6 {
2927
3234
  this.lazyBody.stream = [body, errorCallback];
2928
3235
  }
2929
3236
  /**
2930
- * Download file by streaming it from the file path. This method will setup
2931
- * appropriate `Content-type`, `Content-type` and `Last-modified` headers.
3237
+ * Downloads a file by streaming it with appropriate headers
2932
3238
  *
2933
- * Unexpected stream errors are handled gracefully to avoid memory leaks.
3239
+ * Automatically sets:
3240
+ * - Content-Type from file extension
3241
+ * - Content-Length from file size
3242
+ * - Last-Modified from file stats
3243
+ * - ETag (if enabled)
2934
3244
  *
2935
- * If `raiseErrors=false`, then this method will self handle all the exceptions by
2936
- * writing a generic HTTP response. To have more control over the error, it is
2937
- * recommended to set `raiseErrors=true` and wrap this function inside a
2938
- * `try/catch` statement.
3245
+ * @param filePath - Path to the file to download
3246
+ * @param generateEtag - Whether to generate ETag header
3247
+ * @param errorCallback - Optional custom error handler
2939
3248
  *
2940
3249
  * @example
2941
- * ```js
2942
- * // Errors handled automatically with generic HTTP response
2943
- * response.download('somefile.jpg')
2944
- *
2945
- * // Manually handle (note the await call)
2946
- * try {
2947
- * await response.download('somefile.jpg')
2948
- * } catch (error) {
2949
- * response.status(error.code === 'ENOENT' ? 404 : 500)
2950
- * response.send('Cannot process file')
2951
- * }
3250
+ * ```ts
3251
+ * response.download('/path/to/file.pdf')
3252
+ * response.download('/images/photo.jpg', true, (err) => ['Custom error', 500])
2952
3253
  * ```
2953
3254
  */
2954
3255
  download(filePath, generateEtag = this.#config.etag, errorCallback) {
2955
3256
  this.lazyBody.fileToStream = [filePath, generateEtag, errorCallback];
2956
3257
  }
2957
3258
  /**
2958
- * Download the file by forcing the user to save the file vs displaying it
2959
- * within the browser.
3259
+ * Forces file download by setting Content-Disposition header
2960
3260
  *
2961
- * Internally calls [[download]]
3261
+ * @param filePath - Path to the file to download
3262
+ * @param name - Optional filename for download (defaults to original filename)
3263
+ * @param disposition - Content-Disposition type (defaults to 'attachment')
3264
+ * @param generateEtag - Whether to generate ETag header
3265
+ * @param errorCallback - Optional custom error handler
2962
3266
  */
2963
3267
  attachment(filePath, name, disposition, generateEtag, errorCallback) {
2964
3268
  name = name || filePath;
@@ -2966,11 +3270,14 @@ var Response = class extends Macroable6 {
2966
3270
  return this.download(filePath, generateEtag, errorCallback);
2967
3271
  }
2968
3272
  /**
2969
- * Set the location header.
3273
+ * Sets the Location header for redirects
3274
+ *
3275
+ * @param url - The URL to redirect to
3276
+ * @returns The Response instance for chaining
2970
3277
  *
2971
3278
  * @example
2972
- * ```js
2973
- * response.location('/login')
3279
+ * ```ts
3280
+ * response.location('/dashboard')
2974
3281
  * ```
2975
3282
  */
2976
3283
  location(url) {
@@ -2991,15 +3298,21 @@ var Response = class extends Macroable6 {
2991
3298
  return handler;
2992
3299
  }
2993
3300
  /**
2994
- * Abort the request with custom body and a status code. 400 is
2995
- * used when status is not defined
3301
+ * Aborts the request with a custom response body and status code
3302
+ *
3303
+ * @param body - Response body for the aborted request
3304
+ * @param status - HTTP status code (defaults to 400)
3305
+ * @throws Always throws an HTTP exception
2996
3306
  */
2997
3307
  abort(body, status) {
2998
3308
  throw E_HTTP_REQUEST_ABORTED.invoke(body, status || ResponseStatus.BadRequest);
2999
3309
  }
3000
3310
  /**
3001
- * Abort the request with custom body and a status code when
3002
- * passed condition returns `true`
3311
+ * Conditionally aborts the request if the condition is truthy
3312
+ *
3313
+ * @param condition - Condition to evaluate
3314
+ * @param body - Response body for the aborted request
3315
+ * @param status - HTTP status code (defaults to 400)
3003
3316
  */
3004
3317
  abortIf(condition, body, status) {
3005
3318
  if (condition) {
@@ -3007,8 +3320,11 @@ var Response = class extends Macroable6 {
3007
3320
  }
3008
3321
  }
3009
3322
  /**
3010
- * Abort the request with custom body and a status code when
3011
- * passed condition returns `false`
3323
+ * Conditionally aborts the request if the condition is falsy
3324
+ *
3325
+ * @param condition - Condition to evaluate
3326
+ * @param body - Response body for the aborted request
3327
+ * @param status - HTTP status code (defaults to 400)
3012
3328
  */
3013
3329
  abortUnless(condition, body, status) {
3014
3330
  if (!condition) {
@@ -3016,8 +3332,12 @@ var Response = class extends Macroable6 {
3016
3332
  }
3017
3333
  }
3018
3334
  /**
3019
- * Set signed cookie as the response header. The inline options overrides
3020
- * all options from the config.
3335
+ * Sets a signed cookie in the response
3336
+ *
3337
+ * @param key - Cookie name
3338
+ * @param value - Cookie value
3339
+ * @param options - Cookie options (overrides config defaults)
3340
+ * @returns The Response instance for chaining
3021
3341
  */
3022
3342
  cookie(key, value, options) {
3023
3343
  options = Object.assign({}, this.#config.cookie, options);
@@ -3029,8 +3349,12 @@ var Response = class extends Macroable6 {
3029
3349
  return this;
3030
3350
  }
3031
3351
  /**
3032
- * Set encrypted cookie as the response header. The inline options overrides
3033
- * all options from the config.
3352
+ * Sets an encrypted cookie in the response
3353
+ *
3354
+ * @param key - Cookie name
3355
+ * @param value - Cookie value
3356
+ * @param options - Cookie options (overrides config defaults)
3357
+ * @returns The Response instance for chaining
3034
3358
  */
3035
3359
  encryptedCookie(key, value, options) {
3036
3360
  options = Object.assign({}, this.#config.cookie, options);
@@ -3042,8 +3366,12 @@ var Response = class extends Macroable6 {
3042
3366
  return this;
3043
3367
  }
3044
3368
  /**
3045
- * Set unsigned cookie as the response header. The inline options overrides
3046
- * all options from the config.
3369
+ * Sets a plain (unsigned/unencrypted) cookie in the response
3370
+ *
3371
+ * @param key - Cookie name
3372
+ * @param value - Cookie value
3373
+ * @param options - Cookie options including encode flag
3374
+ * @returns The Response instance for chaining
3047
3375
  */
3048
3376
  plainCookie(key, value, options) {
3049
3377
  options = Object.assign({}, this.#config.cookie, options);
@@ -3055,7 +3383,11 @@ var Response = class extends Macroable6 {
3055
3383
  return this;
3056
3384
  }
3057
3385
  /**
3058
- * Clear existing cookie.
3386
+ * Clears an existing cookie by setting it to expire
3387
+ *
3388
+ * @param key - Cookie name to clear
3389
+ * @param options - Cookie options (should match original cookie options)
3390
+ * @returns The Response instance for chaining
3059
3391
  */
3060
3392
  clearCookie(key, options) {
3061
3393
  options = Object.assign({}, this.#config.cookie, options);
@@ -3066,10 +3398,10 @@ var Response = class extends Macroable6 {
3066
3398
  return this;
3067
3399
  }
3068
3400
  /**
3069
- * Finishes the response by writing the lazy body, when `explicitEnd = true`
3070
- * and response is already pending.
3401
+ * Finalizes and sends the response
3071
3402
  *
3072
- * Calling this method twice or when `explicitEnd = false` is noop.
3403
+ * Writes the buffered body (content, stream, or file) to the client.
3404
+ * This method is idempotent - calling it multiple times has no effect.
3073
3405
  */
3074
3406
  finish() {
3075
3407
  if (!this.isPending) {
@@ -3090,294 +3422,408 @@ var Response = class extends Macroable6 {
3090
3422
  this.#endResponse();
3091
3423
  }
3092
3424
  /**
3093
- * Shorthand method to finish request with "100" status code
3425
+ * Sends a 100 Continue response
3094
3426
  */
3095
3427
  continue() {
3096
3428
  this.status(ResponseStatus.Continue);
3097
3429
  return this.send(null, false);
3098
3430
  }
3099
3431
  /**
3100
- * Shorthand method to finish request with "101" status code
3432
+ * Sends a 101 Switching Protocols response
3101
3433
  */
3102
3434
  switchingProtocols() {
3103
3435
  this.status(ResponseStatus.SwitchingProtocols);
3104
3436
  return this.send(null, false);
3105
3437
  }
3106
3438
  /**
3107
- * Shorthand method to finish request with "200" status code
3439
+ * Sends a 200 OK response
3440
+ *
3441
+ * @param body - Response body
3442
+ * @param generateEtag - Whether to generate ETag header
3108
3443
  */
3109
3444
  ok(body, generateEtag) {
3110
3445
  this.status(ResponseStatus.Ok);
3111
3446
  return this.send(body, generateEtag);
3112
3447
  }
3113
3448
  /**
3114
- * Shorthand method to finish request with "201" status code
3449
+ * Sends a 201 Created response
3450
+ *
3451
+ * @param body - Response body
3452
+ * @param generateEtag - Whether to generate ETag header
3115
3453
  */
3116
3454
  created(body, generateEtag) {
3117
3455
  this.status(ResponseStatus.Created);
3118
3456
  return this.send(body, generateEtag);
3119
3457
  }
3120
3458
  /**
3121
- * Shorthand method to finish request with "202" status code
3459
+ * Sends a 202 Accepted response
3460
+ *
3461
+ * @param body - Response body
3462
+ * @param generateEtag - Whether to generate ETag header
3122
3463
  */
3123
3464
  accepted(body, generateEtag) {
3124
3465
  this.status(ResponseStatus.Accepted);
3125
3466
  return this.send(body, generateEtag);
3126
3467
  }
3127
3468
  /**
3128
- * Shorthand method to finish request with "203" status code
3469
+ * Sends a 203 Non-Authoritative Information response
3470
+ *
3471
+ * @param body - Response body
3472
+ * @param generateEtag - Whether to generate ETag header
3129
3473
  */
3130
3474
  nonAuthoritativeInformation(body, generateEtag) {
3131
3475
  this.status(ResponseStatus.NonAuthoritativeInformation);
3132
3476
  return this.send(body, generateEtag);
3133
3477
  }
3134
3478
  /**
3135
- * Shorthand method to finish request with "204" status code
3479
+ * Sends a 204 No Content response
3136
3480
  */
3137
3481
  noContent() {
3138
3482
  this.status(ResponseStatus.NoContent);
3139
3483
  return this.send(null, false);
3140
3484
  }
3141
3485
  /**
3142
- * Shorthand method to finish request with "205" status code
3486
+ * Sends a 205 Reset Content response
3143
3487
  */
3144
3488
  resetContent() {
3145
3489
  this.status(ResponseStatus.ResetContent);
3146
3490
  return this.send(null, false);
3147
3491
  }
3148
3492
  /**
3149
- * Shorthand method to finish request with "206" status code
3493
+ * Sends a 206 Partial Content response
3494
+ *
3495
+ * @param body - Response body
3496
+ * @param generateEtag - Whether to generate ETag header
3150
3497
  */
3151
3498
  partialContent(body, generateEtag) {
3152
3499
  this.status(ResponseStatus.PartialContent);
3153
3500
  return this.send(body, generateEtag);
3154
3501
  }
3155
3502
  /**
3156
- * Shorthand method to finish request with "300" status code
3503
+ * Sends a 300 Multiple Choices response
3504
+ *
3505
+ * @param body - Response body
3506
+ * @param generateEtag - Whether to generate ETag header
3157
3507
  */
3158
3508
  multipleChoices(body, generateEtag) {
3159
3509
  this.status(ResponseStatus.MultipleChoices);
3160
3510
  return this.send(body, generateEtag);
3161
3511
  }
3162
3512
  /**
3163
- * Shorthand method to finish request with "301" status code
3513
+ * Sends a 301 Moved Permanently response
3514
+ *
3515
+ * @param body - Response body
3516
+ * @param generateEtag - Whether to generate ETag header
3164
3517
  */
3165
3518
  movedPermanently(body, generateEtag) {
3166
3519
  this.status(ResponseStatus.MovedPermanently);
3167
3520
  return this.send(body, generateEtag);
3168
3521
  }
3169
3522
  /**
3170
- * Shorthand method to finish request with "302" status code
3523
+ * Sends a 302 Found (Moved Temporarily) response
3524
+ *
3525
+ * @param body - Response body
3526
+ * @param generateEtag - Whether to generate ETag header
3171
3527
  */
3172
3528
  movedTemporarily(body, generateEtag) {
3173
3529
  this.status(ResponseStatus.Found);
3174
3530
  return this.send(body, generateEtag);
3175
3531
  }
3176
3532
  /**
3177
- * Shorthand method to finish request with "303" status code
3533
+ * Sends a 303 See Other response
3534
+ *
3535
+ * @param body - Response body
3536
+ * @param generateEtag - Whether to generate ETag header
3178
3537
  */
3179
3538
  seeOther(body, generateEtag) {
3180
3539
  this.status(ResponseStatus.SeeOther);
3181
3540
  return this.send(body, generateEtag);
3182
3541
  }
3183
3542
  /**
3184
- * Shorthand method to finish request with "304" status code
3543
+ * Sends a 304 Not Modified response
3544
+ *
3545
+ * @param body - Response body
3546
+ * @param generateEtag - Whether to generate ETag header
3185
3547
  */
3186
3548
  notModified(body, generateEtag) {
3187
3549
  this.status(ResponseStatus.NotModified);
3188
3550
  return this.send(body, generateEtag);
3189
3551
  }
3190
3552
  /**
3191
- * Shorthand method to finish request with "305" status code
3553
+ * Sends a 305 Use Proxy response
3554
+ *
3555
+ * @param body - Response body
3556
+ * @param generateEtag - Whether to generate ETag header
3192
3557
  */
3193
3558
  useProxy(body, generateEtag) {
3194
3559
  this.status(ResponseStatus.UseProxy);
3195
3560
  return this.send(body, generateEtag);
3196
3561
  }
3197
3562
  /**
3198
- * Shorthand method to finish request with "307" status code
3563
+ * Sends a 307 Temporary Redirect response
3564
+ *
3565
+ * @param body - Response body
3566
+ * @param generateEtag - Whether to generate ETag header
3199
3567
  */
3200
3568
  temporaryRedirect(body, generateEtag) {
3201
3569
  this.status(ResponseStatus.TemporaryRedirect);
3202
3570
  return this.send(body, generateEtag);
3203
3571
  }
3204
3572
  /**
3205
- * Shorthand method to finish request with "400" status code
3573
+ * Sends a 400 Bad Request response
3574
+ *
3575
+ * @param body - Response body
3576
+ * @param generateEtag - Whether to generate ETag header
3206
3577
  */
3207
3578
  badRequest(body, generateEtag) {
3208
3579
  this.status(ResponseStatus.BadRequest);
3209
3580
  return this.send(body, generateEtag);
3210
3581
  }
3211
3582
  /**
3212
- * Shorthand method to finish request with "401" status code
3583
+ * Sends a 401 Unauthorized response
3584
+ *
3585
+ * @param body - Response body
3586
+ * @param generateEtag - Whether to generate ETag header
3213
3587
  */
3214
3588
  unauthorized(body, generateEtag) {
3215
3589
  this.status(ResponseStatus.Unauthorized);
3216
3590
  return this.send(body, generateEtag);
3217
3591
  }
3218
3592
  /**
3219
- * Shorthand method to finish request with "402" status code
3593
+ * Sends a 402 Payment Required response
3594
+ *
3595
+ * @param body - Response body
3596
+ * @param generateEtag - Whether to generate ETag header
3220
3597
  */
3221
3598
  paymentRequired(body, generateEtag) {
3222
3599
  this.status(ResponseStatus.PaymentRequired);
3223
3600
  return this.send(body, generateEtag);
3224
3601
  }
3225
3602
  /**
3226
- * Shorthand method to finish request with "403" status code
3603
+ * Sends a 403 Forbidden response
3604
+ *
3605
+ * @param body - Response body
3606
+ * @param generateEtag - Whether to generate ETag header
3227
3607
  */
3228
3608
  forbidden(body, generateEtag) {
3229
3609
  this.status(ResponseStatus.Forbidden);
3230
3610
  return this.send(body, generateEtag);
3231
3611
  }
3232
3612
  /**
3233
- * Shorthand method to finish request with "404" status code
3613
+ * Sends a 404 Not Found response
3614
+ *
3615
+ * @param body - Response body
3616
+ * @param generateEtag - Whether to generate ETag header
3234
3617
  */
3235
3618
  notFound(body, generateEtag) {
3236
3619
  this.status(ResponseStatus.NotFound);
3237
3620
  return this.send(body, generateEtag);
3238
3621
  }
3239
3622
  /**
3240
- * Shorthand method to finish request with "405" status code
3623
+ * Sends a 405 Method Not Allowed response
3624
+ *
3625
+ * @param body - Response body
3626
+ * @param generateEtag - Whether to generate ETag header
3241
3627
  */
3242
3628
  methodNotAllowed(body, generateEtag) {
3243
3629
  this.status(ResponseStatus.MethodNotAllowed);
3244
3630
  return this.send(body, generateEtag);
3245
3631
  }
3246
3632
  /**
3247
- * Shorthand method to finish request with "406" status code
3633
+ * Sends a 406 Not Acceptable response
3634
+ *
3635
+ * @param body - Response body
3636
+ * @param generateEtag - Whether to generate ETag header
3248
3637
  */
3249
3638
  notAcceptable(body, generateEtag) {
3250
3639
  this.status(ResponseStatus.NotAcceptable);
3251
3640
  return this.send(body, generateEtag);
3252
3641
  }
3253
3642
  /**
3254
- * Shorthand method to finish request with "407" status code
3643
+ * Sends a 407 Proxy Authentication Required response
3644
+ *
3645
+ * @param body - Response body
3646
+ * @param generateEtag - Whether to generate ETag header
3255
3647
  */
3256
3648
  proxyAuthenticationRequired(body, generateEtag) {
3257
3649
  this.status(ResponseStatus.ProxyAuthenticationRequired);
3258
3650
  return this.send(body, generateEtag);
3259
3651
  }
3260
3652
  /**
3261
- * Shorthand method to finish request with "408" status code
3653
+ * Sends a 408 Request Timeout response
3654
+ *
3655
+ * @param body - Response body
3656
+ * @param generateEtag - Whether to generate ETag header
3262
3657
  */
3263
3658
  requestTimeout(body, generateEtag) {
3264
3659
  this.status(ResponseStatus.RequestTimeout);
3265
3660
  return this.send(body, generateEtag);
3266
3661
  }
3267
3662
  /**
3268
- * Shorthand method to finish request with "409" status code
3663
+ * Sends a 409 Conflict response
3664
+ *
3665
+ * @param body - Response body
3666
+ * @param generateEtag - Whether to generate ETag header
3269
3667
  */
3270
3668
  conflict(body, generateEtag) {
3271
3669
  this.status(ResponseStatus.Conflict);
3272
3670
  return this.send(body, generateEtag);
3273
3671
  }
3274
3672
  /**
3275
- * Shorthand method to finish request with "401" status code
3673
+ * Sends a 410 Gone response
3674
+ *
3675
+ * @param body - Response body
3676
+ * @param generateEtag - Whether to generate ETag header
3276
3677
  */
3277
3678
  gone(body, generateEtag) {
3278
3679
  this.status(ResponseStatus.Gone);
3279
3680
  return this.send(body, generateEtag);
3280
3681
  }
3281
3682
  /**
3282
- * Shorthand method to finish request with "411" status code
3683
+ * Sends a 411 Length Required response
3684
+ *
3685
+ * @param body - Response body
3686
+ * @param generateEtag - Whether to generate ETag header
3283
3687
  */
3284
3688
  lengthRequired(body, generateEtag) {
3285
3689
  this.status(ResponseStatus.LengthRequired);
3286
3690
  return this.send(body, generateEtag);
3287
3691
  }
3288
3692
  /**
3289
- * Shorthand method to finish request with "412" status code
3693
+ * Sends a 412 Precondition Failed response
3694
+ *
3695
+ * @param body - Response body
3696
+ * @param generateEtag - Whether to generate ETag header
3290
3697
  */
3291
3698
  preconditionFailed(body, generateEtag) {
3292
3699
  this.status(ResponseStatus.PreconditionFailed);
3293
3700
  return this.send(body, generateEtag);
3294
3701
  }
3295
3702
  /**
3296
- * Shorthand method to finish request with "413" status code
3703
+ * Sends a 413 Payload Too Large response
3704
+ *
3705
+ * @param body - Response body
3706
+ * @param generateEtag - Whether to generate ETag header
3297
3707
  */
3298
3708
  requestEntityTooLarge(body, generateEtag) {
3299
3709
  this.status(ResponseStatus.PayloadTooLarge);
3300
3710
  return this.send(body, generateEtag);
3301
3711
  }
3302
3712
  /**
3303
- * Shorthand method to finish request with "414" status code
3713
+ * Sends a 414 URI Too Long response
3714
+ *
3715
+ * @param body - Response body
3716
+ * @param generateEtag - Whether to generate ETag header
3304
3717
  */
3305
3718
  requestUriTooLong(body, generateEtag) {
3306
3719
  this.status(ResponseStatus.URITooLong);
3307
3720
  return this.send(body, generateEtag);
3308
3721
  }
3309
3722
  /**
3310
- * Shorthand method to finish request with "415" status code
3723
+ * Sends a 415 Unsupported Media Type response
3724
+ *
3725
+ * @param body - Response body
3726
+ * @param generateEtag - Whether to generate ETag header
3311
3727
  */
3312
3728
  unsupportedMediaType(body, generateEtag) {
3313
3729
  this.status(ResponseStatus.UnsupportedMediaType);
3314
3730
  return this.send(body, generateEtag);
3315
3731
  }
3316
3732
  /**
3317
- * Shorthand method to finish request with "416" status code
3733
+ * Sends a 416 Range Not Satisfiable response
3734
+ *
3735
+ * @param body - Response body
3736
+ * @param generateEtag - Whether to generate ETag header
3318
3737
  */
3319
3738
  requestedRangeNotSatisfiable(body, generateEtag) {
3320
3739
  this.status(ResponseStatus.RangeNotSatisfiable);
3321
3740
  return this.send(body, generateEtag);
3322
3741
  }
3323
3742
  /**
3324
- * Shorthand method to finish request with "417" status code
3743
+ * Sends a 417 Expectation Failed response
3744
+ *
3745
+ * @param body - Response body
3746
+ * @param generateEtag - Whether to generate ETag header
3325
3747
  */
3326
3748
  expectationFailed(body, generateEtag) {
3327
3749
  this.status(ResponseStatus.ExpectationFailed);
3328
3750
  return this.send(body, generateEtag);
3329
3751
  }
3330
3752
  /**
3331
- * Shorthand method to finish request with "422" status code
3753
+ * Sends a 422 Unprocessable Entity response
3754
+ *
3755
+ * @param body - Response body
3756
+ * @param generateEtag - Whether to generate ETag header
3332
3757
  */
3333
3758
  unprocessableEntity(body, generateEtag) {
3334
3759
  this.status(ResponseStatus.UnprocessableEntity);
3335
3760
  return this.send(body, generateEtag);
3336
3761
  }
3337
3762
  /**
3338
- * Shorthand method to finish request with "429" status code
3763
+ * Sends a 429 Too Many Requests response
3764
+ *
3765
+ * @param body - Response body
3766
+ * @param generateEtag - Whether to generate ETag header
3339
3767
  */
3340
3768
  tooManyRequests(body, generateEtag) {
3341
3769
  this.status(ResponseStatus.TooManyRequests);
3342
3770
  return this.send(body, generateEtag);
3343
3771
  }
3344
3772
  /**
3345
- * Shorthand method to finish request with "500" status code
3773
+ * Sends a 500 Internal Server Error response
3774
+ *
3775
+ * @param body - Response body
3776
+ * @param generateEtag - Whether to generate ETag header
3346
3777
  */
3347
3778
  internalServerError(body, generateEtag) {
3348
3779
  this.status(ResponseStatus.InternalServerError);
3349
3780
  return this.send(body, generateEtag);
3350
3781
  }
3351
3782
  /**
3352
- * Shorthand method to finish request with "501" status code
3783
+ * Sends a 501 Not Implemented response
3784
+ *
3785
+ * @param body - Response body
3786
+ * @param generateEtag - Whether to generate ETag header
3353
3787
  */
3354
3788
  notImplemented(body, generateEtag) {
3355
3789
  this.status(ResponseStatus.NotImplemented);
3356
3790
  return this.send(body, generateEtag);
3357
3791
  }
3358
3792
  /**
3359
- * Shorthand method to finish request with "502" status code
3793
+ * Sends a 502 Bad Gateway response
3794
+ *
3795
+ * @param body - Response body
3796
+ * @param generateEtag - Whether to generate ETag header
3360
3797
  */
3361
3798
  badGateway(body, generateEtag) {
3362
3799
  this.status(ResponseStatus.BadGateway);
3363
3800
  return this.send(body, generateEtag);
3364
3801
  }
3365
3802
  /**
3366
- * Shorthand method to finish request with "503" status code
3803
+ * Sends a 503 Service Unavailable response
3804
+ *
3805
+ * @param body - Response body
3806
+ * @param generateEtag - Whether to generate ETag header
3367
3807
  */
3368
3808
  serviceUnavailable(body, generateEtag) {
3369
3809
  this.status(ResponseStatus.ServiceUnavailable);
3370
3810
  return this.send(body, generateEtag);
3371
3811
  }
3372
3812
  /**
3373
- * Shorthand method to finish request with "504" status code
3813
+ * Sends a 504 Gateway Timeout response
3814
+ *
3815
+ * @param body - Response body
3816
+ * @param generateEtag - Whether to generate ETag header
3374
3817
  */
3375
3818
  gatewayTimeout(body, generateEtag) {
3376
3819
  this.status(ResponseStatus.GatewayTimeout);
3377
3820
  return this.send(body, generateEtag);
3378
3821
  }
3379
3822
  /**
3380
- * Shorthand method to finish request with "505" status code
3823
+ * Sends a 505 HTTP Version Not Supported response
3824
+ *
3825
+ * @param body - Response body
3826
+ * @param generateEtag - Whether to generate ETag header
3381
3827
  */
3382
3828
  httpVersionNotSupported(body, generateEtag) {
3383
3829
  this.status(ResponseStatus.HTTPVersionNotSupported);
@@ -3472,6 +3918,8 @@ var RoutesStore = class {
3472
3918
  * }
3473
3919
  * })
3474
3920
  * ```
3921
+ * @param route - The route to add to the store
3922
+ * @returns Current RoutesStore instance for method chaining
3475
3923
  */
3476
3924
  add(route) {
3477
3925
  if (route.domain !== "root") {
@@ -3492,6 +3940,11 @@ var RoutesStore = class {
3492
3940
  * The domain parameter has to be a registered pattern and not the fully
3493
3941
  * qualified runtime domain. You must call `matchDomain` first to fetch
3494
3942
  * the pattern for qualified domain
3943
+ * @param url - The URL to match
3944
+ * @param method - HTTP method
3945
+ * @param shouldDecodeParam - Whether to decode parameters
3946
+ * @param domain - Optional domain tokens and hostname
3947
+ * @returns Matched route or null if no match found
3495
3948
  */
3496
3949
  match(url, method, shouldDecodeParam, domain) {
3497
3950
  const domainName = domain?.tokens[0]?.old || "root";
@@ -3517,6 +3970,8 @@ var RoutesStore = class {
3517
3970
  }
3518
3971
  /**
3519
3972
  * Match hostname against registered domains.
3973
+ * @param hostname - The hostname to match
3974
+ * @returns Array of matched domain tokens
3520
3975
  */
3521
3976
  matchDomain(hostname) {
3522
3977
  if (!hostname || !this.usingDomains) {
@@ -3526,6 +3981,84 @@ var RoutesStore = class {
3526
3981
  }
3527
3982
  };
3528
3983
 
3984
+ // src/router/url_builder.ts
3985
+ function createUrlBuilder(router, searchParamsStringifier) {
3986
+ let domainsList;
3987
+ function createUrlForRoute(identifier, params, options, method) {
3988
+ if (!domainsList) {
3989
+ domainsList = Object.keys(router.toJSON()).filter((domain2) => domain2 !== "root");
3990
+ }
3991
+ const domain = domainsList.find((name) => identifier.startsWith(`${name}@`));
3992
+ const routeIdentifier = domain ? identifier.replace(new RegExp(`^${domain}@`), "") : identifier;
3993
+ const route = router.findOrFail(routeIdentifier, domain, method, true);
3994
+ return createURL(
3995
+ route.name ?? route.pattern,
3996
+ route.tokens,
3997
+ searchParamsStringifier,
3998
+ params,
3999
+ options
4000
+ );
4001
+ }
4002
+ const urlFor = function route(...[identifier, params, options]) {
4003
+ return createUrlForRoute(identifier, params, options);
4004
+ };
4005
+ urlFor.get = function urlForMethodGet(...[identifier, params, options]) {
4006
+ return {
4007
+ url: createUrlForRoute(identifier, params, options, "GET"),
4008
+ method: "get",
4009
+ toString() {
4010
+ return this.url;
4011
+ }
4012
+ };
4013
+ };
4014
+ urlFor.post = function urlForMethodPost(...[identifier, params, options]) {
4015
+ return {
4016
+ url: createUrlForRoute(identifier, params, options, "POST"),
4017
+ method: "post",
4018
+ toString() {
4019
+ return this.url;
4020
+ }
4021
+ };
4022
+ };
4023
+ urlFor.put = function urlForMethodPut(...[identifier, params, options]) {
4024
+ return {
4025
+ url: createUrlForRoute(identifier, params, options, "PUT"),
4026
+ method: "put",
4027
+ toString() {
4028
+ return this.url;
4029
+ }
4030
+ };
4031
+ };
4032
+ urlFor.patch = function urlForMethodPatch(...[identifier, params, options]) {
4033
+ return {
4034
+ url: createUrlForRoute(identifier, params, options, "PATCH"),
4035
+ method: "patch",
4036
+ toString() {
4037
+ return this.url;
4038
+ }
4039
+ };
4040
+ };
4041
+ urlFor.delete = function urlForMethodDelete(...[identifier, params, options]) {
4042
+ return {
4043
+ url: createUrlForRoute(identifier, params, options, "DELETE"),
4044
+ method: "delete",
4045
+ toString() {
4046
+ return this.url;
4047
+ }
4048
+ };
4049
+ };
4050
+ urlFor.method = function urlForCustomMethod(method, ...[identifier, params, options]) {
4051
+ return {
4052
+ url: createUrlForRoute(identifier, params, options, method),
4053
+ method,
4054
+ toString() {
4055
+ return this.url;
4056
+ }
4057
+ };
4058
+ };
4059
+ return urlFor;
4060
+ }
4061
+
3529
4062
  // src/router/legacy/url_builder.ts
3530
4063
  var UrlBuilder = class {
3531
4064
  /**
@@ -3549,7 +4082,15 @@ var UrlBuilder = class {
3549
4082
  * Route finder for finding route pattern
3550
4083
  */
3551
4084
  #router;
4085
+ /**
4086
+ * Domain to use for URL generation
4087
+ */
3552
4088
  #domain;
4089
+ /**
4090
+ * Creates a new UrlBuilder instance
4091
+ * @param router - The router instance
4092
+ * @param domain - Optional domain for URL generation
4093
+ */
3553
4094
  constructor(router, domain) {
3554
4095
  this.#router = router;
3555
4096
  this.#domain = domain;
@@ -3604,6 +4145,8 @@ var UrlBuilder = class {
3604
4145
  *
3605
4146
  * @deprecated
3606
4147
  * Instead use "@adonisjs/core/services/url_builder" instead
4148
+ * @param identifier - Route identifier to generate URL for
4149
+ * @returns Generated URL string
3607
4150
  */
3608
4151
  make(identifier) {
3609
4152
  return this.#router.makeUrl(identifier, this.#params, {
@@ -3639,12 +4182,14 @@ var RouteMatchers = class extends Macroable7 {
3639
4182
  /**
3640
4183
  * Enforce value to be a number and also casts it to number data
3641
4184
  * type
4185
+ * @returns Route matcher configuration for numeric values
3642
4186
  */
3643
4187
  number() {
3644
4188
  return { match: /^[0-9]+$/, cast: (value) => Number(value) };
3645
4189
  }
3646
4190
  /**
3647
4191
  * Enforce value to be formatted as uuid
4192
+ * @returns Route matcher configuration for UUID values
3648
4193
  */
3649
4194
  uuid() {
3650
4195
  return {
@@ -3654,133 +4199,13 @@ var RouteMatchers = class extends Macroable7 {
3654
4199
  }
3655
4200
  /**
3656
4201
  * Enforce value to be formatted as slug
4202
+ * @returns Route matcher configuration for slug values
3657
4203
  */
3658
4204
  slug() {
3659
4205
  return { match: /^[^\s-_](?!.*?[-_]{2,})([a-z0-9-\\]{1,})[^\s]*[^-_\s]$/ };
3660
4206
  }
3661
4207
  };
3662
4208
 
3663
- // src/router/url_builder.ts
3664
- function createURL(identifier, tokens, searchParamsStringifier, params, options) {
3665
- const uriSegments = [];
3666
- const paramsArray = Array.isArray(params) ? params : null;
3667
- const paramsObject = !Array.isArray(params) ? params ?? {} : {};
3668
- let paramsIndex = 0;
3669
- for (const token of tokens) {
3670
- if (token.type === 0) {
3671
- uriSegments.push(token.val === "/" ? "" : `${token.val}${token.end}`);
3672
- continue;
3673
- }
3674
- if (token.type === 2) {
3675
- const values = paramsArray ? paramsArray.slice(paramsIndex) : paramsObject["*"];
3676
- if (!Array.isArray(values) || !values.length) {
3677
- throw new Error(
3678
- `Cannot make URL for "${identifier}". Invalid value provided for the wildcard param`
3679
- );
3680
- }
3681
- uriSegments.push(`${values.join("/")}${token.end}`);
3682
- break;
3683
- }
3684
- const paramName = token.val;
3685
- const value = paramsArray ? paramsArray[paramsIndex] : paramsObject[paramName];
3686
- const isDefined = value !== void 0 && value !== null;
3687
- if (token.type === 1 && !isDefined) {
3688
- throw new Error(
3689
- `Cannot make URL for "${identifier}". Missing value for the "${paramName}" param`
3690
- );
3691
- }
3692
- if (isDefined) {
3693
- uriSegments.push(`${value}${token.end}`);
3694
- }
3695
- paramsIndex++;
3696
- }
3697
- let URI = `/${uriSegments.join("/")}`;
3698
- if (options?.prefixUrl) {
3699
- URI = `${options?.prefixUrl.replace(/\/$/, "")}${URI}`;
3700
- }
3701
- if (options?.qs) {
3702
- const queryString = searchParamsStringifier(options?.qs);
3703
- URI = queryString ? `${URI}?${queryString}` : URI;
3704
- }
3705
- return URI;
3706
- }
3707
- function createUrlBuilder(router, searchParamsStringifier) {
3708
- let domainsList;
3709
- function createUrlForRoute(identifier, params, options, method) {
3710
- if (!domainsList) {
3711
- domainsList = Object.keys(router.toJSON()).filter((domain2) => domain2 !== "root");
3712
- }
3713
- const domain = domainsList.find((name) => identifier.startsWith(`${name}@`));
3714
- const routeIdentifier = domain ? identifier.replace(new RegExp(`^${domain}@`), "") : identifier;
3715
- const route = router.findOrFail(routeIdentifier, domain, method, true);
3716
- return createURL(
3717
- route.name ?? route.pattern,
3718
- route.tokens,
3719
- searchParamsStringifier,
3720
- params,
3721
- options
3722
- );
3723
- }
3724
- const urlFor = function route(...[identifier, params, options]) {
3725
- return createUrlForRoute(identifier, params, options);
3726
- };
3727
- urlFor.get = function urlForMethodGet(...[identifier, params, options]) {
3728
- return {
3729
- url: createUrlForRoute(identifier, params, options, "GET"),
3730
- method: "get",
3731
- toString() {
3732
- return this.url;
3733
- }
3734
- };
3735
- };
3736
- urlFor.post = function urlForMethodPost(...[identifier, params, options]) {
3737
- return {
3738
- url: createUrlForRoute(identifier, params, options, "POST"),
3739
- method: "post",
3740
- toString() {
3741
- return this.url;
3742
- }
3743
- };
3744
- };
3745
- urlFor.put = function urlForMethodPut(...[identifier, params, options]) {
3746
- return {
3747
- url: createUrlForRoute(identifier, params, options, "PUT"),
3748
- method: "put",
3749
- toString() {
3750
- return this.url;
3751
- }
3752
- };
3753
- };
3754
- urlFor.patch = function urlForMethodPatch(...[identifier, params, options]) {
3755
- return {
3756
- url: createUrlForRoute(identifier, params, options, "PATCH"),
3757
- method: "patch",
3758
- toString() {
3759
- return this.url;
3760
- }
3761
- };
3762
- };
3763
- urlFor.delete = function urlForMethodDelete(...[identifier, params, options]) {
3764
- return {
3765
- url: createUrlForRoute(identifier, params, options, "DELETE"),
3766
- method: "delete",
3767
- toString() {
3768
- return this.url;
3769
- }
3770
- };
3771
- };
3772
- urlFor.method = function urlForCustomMethod(method, ...[identifier, params, options]) {
3773
- return {
3774
- url: createUrlForRoute(identifier, params, options, method),
3775
- method,
3776
- toString() {
3777
- return this.url;
3778
- }
3779
- };
3780
- };
3781
- return urlFor;
3782
- }
3783
-
3784
4209
  // src/define_middleware.ts
3785
4210
  import { moduleImporter as moduleImporter2 } from "@adonisjs/fold";
3786
4211
  function middlewareReferenceBuilder(name, middleware) {
@@ -3805,20 +4230,6 @@ function defineNamedMiddleware(collection) {
3805
4230
  }
3806
4231
 
3807
4232
  // src/router/signed_url_builder.ts
3808
- function createSignedURL(identifier, tokens, searchParamsStringifier, encryption, params, options) {
3809
- const signature = encryption.verifier.sign(
3810
- createURL(identifier, tokens, searchParamsStringifier, params, {
3811
- ...options,
3812
- prefixUrl: void 0
3813
- }),
3814
- options?.expiresIn,
3815
- options?.purpose
3816
- );
3817
- return createURL(identifier, tokens, searchParamsStringifier, params, {
3818
- ...options,
3819
- qs: { ...options?.qs, signature }
3820
- });
3821
- }
3822
4233
  function createSignedUrlBuilder(router, encryption, searchParamsStringifier) {
3823
4234
  let domainsList;
3824
4235
  function createSignedUrlForRoute(identifier, params, options, method) {
@@ -3966,6 +4377,12 @@ var Router = class {
3966
4377
  * List of route references kept for lookup.
3967
4378
  */
3968
4379
  routes = {};
4380
+ /**
4381
+ * Creates a new Router instance
4382
+ * @param app - The AdonisJS application instance
4383
+ * @param encryption - Encryption service for signed URLs
4384
+ * @param qsParser - Query string parser for URL generation
4385
+ */
3969
4386
  constructor(app, encryption, qsParser) {
3970
4387
  this.#app = app;
3971
4388
  this.#encryption = encryption;
@@ -3996,6 +4413,8 @@ var Router = class {
3996
4413
  }
3997
4414
  /**
3998
4415
  * Parses the route pattern
4416
+ * @param pattern - The route pattern to parse
4417
+ * @param matchers - Optional route matchers
3999
4418
  */
4000
4419
  parsePattern(pattern, matchers) {
4001
4420
  return parseRoute(pattern, matchers);
@@ -4004,6 +4423,8 @@ var Router = class {
4004
4423
  * Define an array of middleware to use on all the routes.
4005
4424
  * Calling this method multiple times pushes to the
4006
4425
  * existing list of middleware
4426
+ * @param middleware - Array of middleware classes to apply globally
4427
+ * @returns Current Router instance for method chaining
4007
4428
  */
4008
4429
  use(middleware) {
4009
4430
  middleware.forEach(
@@ -4018,12 +4439,18 @@ var Router = class {
4018
4439
  * Define a collection of named middleware. The defined collection is
4019
4440
  * not registered anywhere, but instead converted in a new collection
4020
4441
  * of functions you can apply on the routes, or router groups.
4442
+ * @param collection - Object mapping middleware names to middleware classes
4443
+ * @returns Named middleware functions
4021
4444
  */
4022
4445
  named(collection) {
4023
4446
  return defineNamedMiddleware(collection);
4024
4447
  }
4025
4448
  /**
4026
4449
  * Add route for a given pattern and methods
4450
+ * @param pattern - The route pattern
4451
+ * @param methods - Array of HTTP methods
4452
+ * @param handler - Route handler (function, string, or controller tuple)
4453
+ * @returns The created route instance
4027
4454
  */
4028
4455
  route(pattern, methods, handler) {
4029
4456
  const route = new Route(this.#app, this.#middleware, {
@@ -4037,6 +4464,9 @@ var Router = class {
4037
4464
  }
4038
4465
  /**
4039
4466
  * Define a route that handles all common HTTP methods
4467
+ * @param pattern - The route pattern
4468
+ * @param handler - Route handler (function, string, or controller tuple)
4469
+ * @returns The created route instance
4040
4470
  */
4041
4471
  any(pattern, handler) {
4042
4472
  return this.route(
@@ -4047,30 +4477,45 @@ var Router = class {
4047
4477
  }
4048
4478
  /**
4049
4479
  * Define `GET` route
4480
+ * @param pattern - The route pattern
4481
+ * @param handler - Route handler (function, string, or controller tuple)
4482
+ * @returns The created route instance
4050
4483
  */
4051
4484
  get(pattern, handler) {
4052
4485
  return this.route(pattern, ["GET", "HEAD"], handler);
4053
4486
  }
4054
4487
  /**
4055
4488
  * Define `POST` route
4489
+ * @param pattern - The route pattern
4490
+ * @param handler - Route handler (function, string, or controller tuple)
4491
+ * @returns The created route instance
4056
4492
  */
4057
4493
  post(pattern, handler) {
4058
4494
  return this.route(pattern, ["POST"], handler);
4059
4495
  }
4060
4496
  /**
4061
4497
  * Define `PUT` route
4498
+ * @param pattern - The route pattern
4499
+ * @param handler - Route handler (function, string, or controller tuple)
4500
+ * @returns The created route instance
4062
4501
  */
4063
4502
  put(pattern, handler) {
4064
4503
  return this.route(pattern, ["PUT"], handler);
4065
4504
  }
4066
4505
  /**
4067
4506
  * Define `PATCH` route
4507
+ * @param pattern - The route pattern
4508
+ * @param handler - Route handler (function, string, or controller tuple)
4509
+ * @returns The created route instance
4068
4510
  */
4069
4511
  patch(pattern, handler) {
4070
4512
  return this.route(pattern, ["PATCH"], handler);
4071
4513
  }
4072
4514
  /**
4073
4515
  * Define `DELETE` route
4516
+ * @param pattern - The route pattern
4517
+ * @param handler - Route handler (function, string, or controller tuple)
4518
+ * @returns The created route instance
4074
4519
  */
4075
4520
  delete(pattern, handler) {
4076
4521
  return this.route(pattern, ["DELETE"], handler);
@@ -4078,6 +4523,8 @@ var Router = class {
4078
4523
  /**
4079
4524
  * Creates a group of routes. A route group can apply transforms
4080
4525
  * to routes in bulk
4526
+ * @param callback - Function that defines routes within the group
4527
+ * @returns The created route group instance
4081
4528
  */
4082
4529
  group(callback) {
4083
4530
  const group = new RouteGroup([]);
@@ -4089,6 +4536,9 @@ var Router = class {
4089
4536
  }
4090
4537
  /**
4091
4538
  * Registers a route resource with conventional set of routes
4539
+ * @param resource - The resource name
4540
+ * @param controller - Controller to handle the resource
4541
+ * @returns The created route resource instance
4092
4542
  */
4093
4543
  resource(resource, controller) {
4094
4544
  const resourceInstance = new RouteResource(this.#app, this.#middleware, {
@@ -4102,6 +4552,9 @@ var Router = class {
4102
4552
  }
4103
4553
  /**
4104
4554
  * Register a route resource with shallow nested routes.
4555
+ * @param resource - The resource name
4556
+ * @param controller - Controller to handle the resource
4557
+ * @returns The created route resource instance
4105
4558
  */
4106
4559
  shallowResource(resource, controller) {
4107
4560
  const resourceInstance = new RouteResource(this.#app, this.#middleware, {
@@ -4115,6 +4568,8 @@ var Router = class {
4115
4568
  }
4116
4569
  /**
4117
4570
  * Returns a brisk route instance for a given URL pattern
4571
+ * @param pattern - The route pattern
4572
+ * @returns The created brisk route instance
4118
4573
  */
4119
4574
  on(pattern) {
4120
4575
  const briskRoute = new BriskRoute(this.#app, this.#middleware, {
@@ -4127,6 +4582,9 @@ var Router = class {
4127
4582
  /**
4128
4583
  * Define matcher for a given param. The global params are applied
4129
4584
  * on all the routes (unless overridden at the route level).
4585
+ * @param param - The parameter name to match
4586
+ * @param matcher - The matcher pattern (RegExp, string, or RouteMatcher)
4587
+ * @returns Current Router instance for method chaining
4130
4588
  */
4131
4589
  where(param, matcher) {
4132
4590
  if (typeof matcher === "string") {
@@ -4179,6 +4637,11 @@ var Router = class {
4179
4637
  *
4180
4638
  * When "disableLegacyLookup" is set, the lookup will be performed
4181
4639
  * only using the route name
4640
+ * @param routeIdentifier - Route name, pattern, or controller reference
4641
+ * @param domain - Optional domain to search within
4642
+ * @param method - Optional HTTP method to filter by
4643
+ * @param disableLegacyLookup - Whether to disable legacy lookup strategies
4644
+ * @returns Found route or null if not found
4182
4645
  */
4183
4646
  find(routeIdentifier, domain, method, disableLegacyLookup) {
4184
4647
  if (!domain) {
@@ -4220,6 +4683,12 @@ var Router = class {
4220
4683
  *
4221
4684
  * When "disableLegacyLookup" is set, the lookup will be performed
4222
4685
  * only using the route name
4686
+ * @param routeIdentifier - Route name, pattern, or controller reference
4687
+ * @param domain - Optional domain to search within
4688
+ * @param method - Optional HTTP method to filter by
4689
+ * @param disableLegacyLookup - Whether to disable legacy lookup strategies
4690
+ * @returns Found route
4691
+ * @throws Error when route is not found
4223
4692
  */
4224
4693
  findOrFail(routeIdentifier, domain, method, disableLegacyLookup) {
4225
4694
  const route = this.find(routeIdentifier, domain, method, disableLegacyLookup);
@@ -4236,12 +4705,18 @@ var Router = class {
4236
4705
  * When "followLookupStrategy" is enabled, the lookup will be performed
4237
4706
  * on the basis of the lookup strategy enabled via the "lookupStrategies"
4238
4707
  * method. The default lookupStrategy is "name" and "pattern".
4708
+ * @param routeIdentifier - Route name, pattern, or controller reference
4709
+ * @param domain - Optional domain to search within
4710
+ * @param method - Optional HTTP method to filter by
4711
+ * @param followLookupStrategy - Whether to follow the configured lookup strategy
4712
+ * @returns True if route exists, false otherwise
4239
4713
  */
4240
4714
  has(routeIdentifier, domain, method, followLookupStrategy) {
4241
4715
  return !!this.find(routeIdentifier, domain, method, followLookupStrategy);
4242
4716
  }
4243
4717
  /**
4244
4718
  * Returns a list of routes grouped by their domain names
4719
+ * @returns Object mapping domain names to route arrays
4245
4720
  */
4246
4721
  toJSON() {
4247
4722
  return this.routes;
@@ -4250,6 +4725,8 @@ var Router = class {
4250
4725
  * Generates types for the URL builder. These types must
4251
4726
  * be written inside a file for the URL builder to
4252
4727
  * pick them up.
4728
+ * @param indentation - Indentation level for generated types
4729
+ * @returns Generated TypeScript types as string
4253
4730
  */
4254
4731
  generateTypes(indentation = 0) {
4255
4732
  const routesList = {};
@@ -4318,6 +4795,11 @@ var Router = class {
4318
4795
  }
4319
4796
  /**
4320
4797
  * Find route for a given URL, method and optionally domain
4798
+ * @param uri - The URI to match
4799
+ * @param method - HTTP method
4800
+ * @param shouldDecodeParam - Whether to decode parameters
4801
+ * @param hostname - Optional hostname for domain matching
4802
+ * @returns Matched route or null if no match found
4321
4803
  */
4322
4804
  match(uri, method, shouldDecodeParam, hostname) {
4323
4805
  const matchingDomain = this.#store.matchDomain(hostname);
@@ -4402,27 +4884,13 @@ import { RuntimeException as RuntimeException6 } from "@poppinss/utils/exception
4402
4884
  // src/http_context/local_storage.ts
4403
4885
  import { AsyncLocalStorage } from "async_hooks";
4404
4886
  var asyncLocalStorage = {
4405
- /**
4406
- * Check if the async local storage for the HTTP
4407
- * context is enabled or not
4408
- */
4409
4887
  isEnabled: false,
4410
- /**
4411
- * HTTP context storage instance for the current scope
4412
- */
4413
4888
  storage: null,
4414
- /**
4415
- * Create the storage instance. This method must be called only
4416
- * once.
4417
- */
4418
4889
  create() {
4419
4890
  this.isEnabled = true;
4420
4891
  this.storage = new AsyncLocalStorage();
4421
4892
  return this.storage;
4422
4893
  },
4423
- /**
4424
- * Destroy the create storage instance
4425
- */
4426
4894
  destroy() {
4427
4895
  this.isEnabled = false;
4428
4896
  this.storage = null;
@@ -4431,6 +4899,14 @@ var asyncLocalStorage = {
4431
4899
 
4432
4900
  // src/http_context/main.ts
4433
4901
  var HttpContext = class extends Macroable8 {
4902
+ /**
4903
+ * Creates a new HttpContext instance
4904
+ *
4905
+ * @param {Request} request - The HTTP request instance
4906
+ * @param {Response} response - The HTTP response instance
4907
+ * @param {Logger} logger - The logger instance
4908
+ * @param {ContainerResolver<any>} containerResolver - The IoC container resolver
4909
+ */
4434
4910
  constructor(request, response, logger, containerResolver) {
4435
4911
  super();
4436
4912
  this.request = request;
@@ -4517,13 +4993,30 @@ import { moduleCaller as moduleCaller2, moduleImporter as moduleImporter4 } from
4517
4993
  // src/qs.ts
4518
4994
  import { parse as parse2, stringify } from "qs";
4519
4995
  var Qs = class {
4996
+ /**
4997
+ * Configuration object containing parse and stringify options for query strings
4998
+ */
4520
4999
  #config;
5000
+ /**
5001
+ * Creates a new query string parser instance with the provided configuration
5002
+ * @param config - Configuration object with parse and stringify options
5003
+ */
4521
5004
  constructor(config) {
4522
5005
  this.#config = config;
4523
5006
  }
5007
+ /**
5008
+ * Parses a query string into a JavaScript object using the configured options
5009
+ * @param value - Query string to parse (e.g., "foo=bar&baz=qux")
5010
+ * @returns Parsed object representation of the query string
5011
+ */
4524
5012
  parse = (value) => {
4525
5013
  return parse2(value, this.#config.parse);
4526
5014
  };
5015
+ /**
5016
+ * Converts a JavaScript object into a query string using the configured options
5017
+ * @param value - Object to convert to query string
5018
+ * @returns Stringified query string representation of the object
5019
+ */
4527
5020
  stringify = (value) => {
4528
5021
  return stringify(value, this.#config.stringify);
4529
5022
  };
@@ -4566,7 +5059,7 @@ function middlewareHandler(resolver, ctx) {
4566
5059
  debug_default("executing middleware %s", fn.name);
4567
5060
  return httpMiddleware.tracePromise(
4568
5061
  fn.handle,
4569
- fn,
5062
+ httpMiddleware.hasSubscribers ? { middleware: fn } : void 0,
4570
5063
  void 0,
4571
5064
  resolver,
4572
5065
  ctx,
@@ -4577,9 +5070,12 @@ function middlewareHandler(resolver, ctx) {
4577
5070
 
4578
5071
  // src/server/main.ts
4579
5072
  var Server = class {
5073
+ /**
5074
+ * Flag indicating whether the server has been booted and initialized
5075
+ */
4580
5076
  #booted = false;
4581
5077
  /**
4582
- * The default error handler to use
5078
+ * Built-in fallback error handler used when no custom handler is registered
4583
5079
  */
4584
5080
  #defaultErrorHandler = {
4585
5081
  report() {
@@ -4589,86 +5085,88 @@ var Server = class {
4589
5085
  }
4590
5086
  };
4591
5087
  /**
4592
- * Logger instance, a child logger is added
4593
- * to the context to have request specific
4594
- * logging capabilities.
5088
+ * Logger instance for server-level logging (child loggers are created per request)
4595
5089
  */
4596
5090
  #logger;
4597
5091
  /**
4598
- * Registered error handler (if any)
5092
+ * Lazy import reference to the custom error handler class
4599
5093
  */
4600
5094
  #errorHandler;
4601
5095
  /**
4602
- * Resolved error handler is an instance of the lazily imported error
4603
- * handler class.
5096
+ * Active error handler instance (either custom or default)
4604
5097
  */
4605
5098
  #resolvedErrorHandler = this.#defaultErrorHandler;
4606
5099
  /**
4607
- * Emitter is required to notify when a request finishes
5100
+ * Event emitter for HTTP server lifecycle events
4608
5101
  */
4609
5102
  #emitter;
4610
5103
  /**
4611
- * The application instance to be shared with the router
5104
+ * AdonisJS application instance providing IoC container and configuration
4612
5105
  */
4613
5106
  #app;
4614
5107
  /**
4615
- * The encryption instance to be shared with the router
5108
+ * Encryption service for secure cookie handling and data encryption
4616
5109
  */
4617
5110
  #encryption;
4618
5111
  /**
4619
- * Server config
5112
+ * Server configuration settings including timeouts, middleware options, etc.
4620
5113
  */
4621
5114
  #config;
4622
5115
  /**
4623
- * Query string parser used by the server
5116
+ * Query string parser instance for URL parameter processing
4624
5117
  */
4625
5118
  #qsParser;
4626
5119
  /**
4627
- * Server middleware stack runs on every incoming HTTP request
5120
+ * Compiled middleware stack that executes on every incoming HTTP request
4628
5121
  */
4629
5122
  #serverMiddlewareStack;
4630
5123
  /**
4631
- * Reference to the router used by the server
5124
+ * Router instance responsible for route registration and matching
4632
5125
  */
4633
5126
  #router;
4634
5127
  /**
4635
- * Reference to the underlying Node HTTP server in use
5128
+ * Reference to the underlying Node.js HTTP or HTTPS server instance
4636
5129
  */
4637
5130
  #nodeHttpServer;
4638
5131
  /**
4639
- * Middleware store to be shared with the routes
5132
+ * Collection of registered global middleware before compilation
4640
5133
  */
4641
5134
  #middleware = [];
4642
5135
  /**
4643
- * The request error response is attached to the middleware
4644
- * pipeline to intercept errors and invoke the user
4645
- * registered error handler.
4646
- *
4647
- * We share this with the route middleware pipeline as well,
4648
- * so that it does not throw any exceptions
5136
+ * Error responder function that handles exceptions in middleware and routes.
5137
+ * Reports errors and delegates handling to the configured error handler.
4649
5138
  */
4650
5139
  #requestErrorResponder = (error, ctx) => {
4651
5140
  this.#resolvedErrorHandler.report(error, ctx);
4652
5141
  return httpExceptionHandler.tracePromise(
4653
5142
  this.#resolvedErrorHandler.handle,
4654
5143
  void 0,
4655
- void 0,
5144
+ this.#resolvedErrorHandler,
4656
5145
  error,
4657
5146
  ctx
4658
5147
  );
4659
5148
  };
4660
5149
  /**
4661
- * Check if the server has already been booted
5150
+ * Indicates whether the server has completed its boot process
4662
5151
  */
4663
5152
  get booted() {
4664
5153
  return this.#booted;
4665
5154
  }
4666
5155
  /**
4667
- * Know if async local storage is enabled or not.
5156
+ * Indicates whether async local storage is enabled for request context
4668
5157
  */
4669
5158
  get usingAsyncLocalStorage() {
4670
5159
  return asyncLocalStorage.isEnabled;
4671
5160
  }
5161
+ /**
5162
+ * Creates a new Server instance
5163
+ *
5164
+ * @param app - AdonisJS application instance
5165
+ * @param encryption - Encryption service for secure operations
5166
+ * @param emitter - Event emitter for server lifecycle events
5167
+ * @param logger - Logger instance for server operations
5168
+ * @param config - Server configuration settings
5169
+ */
4672
5170
  constructor(app, encryption, emitter, logger, config) {
4673
5171
  this.#app = app;
4674
5172
  this.#emitter = emitter;
@@ -4681,7 +5179,7 @@ var Server = class {
4681
5179
  debug_default("server config: %O", this.#config);
4682
5180
  }
4683
5181
  /**
4684
- * Create async local storage store when enabled
5182
+ * Initializes or destroys async local storage based on configuration
4685
5183
  */
4686
5184
  #createAsyncLocalStore() {
4687
5185
  if (this.#config.useAsyncLocalStorage) {
@@ -4692,7 +5190,7 @@ var Server = class {
4692
5190
  }
4693
5191
  }
4694
5192
  /**
4695
- * Creates an instance of the server middleware stack
5193
+ * Compiles registered middleware into a frozen middleware stack for execution
4696
5194
  */
4697
5195
  #createServerMiddlewareStack() {
4698
5196
  this.#serverMiddlewareStack = new Middleware2();
@@ -4701,7 +5199,11 @@ var Server = class {
4701
5199
  this.#middleware = [];
4702
5200
  }
4703
5201
  /**
4704
- * Handles the HTTP request
5202
+ * Processes an HTTP request through the middleware pipeline and routing
5203
+ *
5204
+ * @param ctx - HTTP context containing request/response objects
5205
+ * @param resolver - Container resolver for dependency injection
5206
+ * @returns Promise that resolves when request processing is complete
4705
5207
  */
4706
5208
  #handleRequest(ctx, resolver) {
4707
5209
  return this.#serverMiddlewareStack.runner().errorHandler((error) => this.#requestErrorResponder(error, ctx)).finalHandler(routeFinder(this.#router, resolver, ctx, this.#requestErrorResponder)).run(middlewareHandler(resolver, ctx)).catch((error) => {
@@ -4710,7 +5212,10 @@ var Server = class {
4710
5212
  }).finally(writeResponse(ctx));
4711
5213
  }
4712
5214
  /**
4713
- * Creates a pipeline of middleware.
5215
+ * Creates a testing middleware pipeline for unit/integration testing
5216
+ *
5217
+ * @param middleware - Array of middleware classes to include in pipeline
5218
+ * @returns TestingMiddlewarePipeline instance for test execution
4714
5219
  */
4715
5220
  pipeline(middleware) {
4716
5221
  const middlewareStack = new Middleware2();
@@ -4739,9 +5244,10 @@ var Server = class {
4739
5244
  };
4740
5245
  }
4741
5246
  /**
4742
- * Define an array of middleware to use on all the incoming HTTP request.
4743
- * Calling this method multiple times pushes to the existing list
4744
- * of middleware
5247
+ * Registers global middleware to run on all incoming HTTP requests
5248
+ *
5249
+ * @param middleware - Array of lazy-imported middleware classes
5250
+ * @returns The Server instance for method chaining
4745
5251
  */
4746
5252
  use(middleware) {
4747
5253
  middleware.forEach(
@@ -4753,18 +5259,22 @@ var Server = class {
4753
5259
  return this;
4754
5260
  }
4755
5261
  /**
4756
- * Register a custom error handler for HTTP requests.
4757
- * All errors will be reported to this method
5262
+ * Registers a custom error handler for HTTP request processing
5263
+ *
5264
+ * @param handler - Lazy import of the error handler class
5265
+ * @returns The Server instance for method chaining
4758
5266
  */
4759
5267
  errorHandler(handler) {
4760
5268
  this.#errorHandler = handler;
4761
5269
  return this;
4762
5270
  }
4763
5271
  /**
4764
- * Boot the server. Calling this method performs the following actions.
5272
+ * Initializes the server by compiling middleware, committing routes, and resolving handlers
4765
5273
  *
4766
- * - Register routes with the store.
4767
- * - Resolve and construct the error handler.
5274
+ * Performs the following operations:
5275
+ * - Compiles the middleware stack
5276
+ * - Commits registered routes to the router
5277
+ * - Resolves and instantiates the custom error handler
4768
5278
  */
4769
5279
  async boot() {
4770
5280
  if (this.#booted) {
@@ -4783,7 +5293,9 @@ var Server = class {
4783
5293
  this.#booted = true;
4784
5294
  }
4785
5295
  /**
4786
- * Set the HTTP server instance used to listen for requests.
5296
+ * Configures the underlying Node.js HTTP/HTTPS server with timeout settings
5297
+ *
5298
+ * @param server - Node.js HTTP or HTTPS server instance
4787
5299
  */
4788
5300
  setNodeServer(server) {
4789
5301
  server.timeout = this.#config.timeout ?? server.timeout;
@@ -4793,33 +5305,48 @@ var Server = class {
4793
5305
  this.#nodeHttpServer = server;
4794
5306
  }
4795
5307
  /**
4796
- * Returns reference to the underlying HTTP server
4797
- * in use
5308
+ * Gets the underlying Node.js HTTP/HTTPS server instance
5309
+ *
5310
+ * @returns The configured server instance or undefined if not set
4798
5311
  */
4799
5312
  getNodeServer() {
4800
5313
  return this.#nodeHttpServer;
4801
5314
  }
4802
5315
  /**
4803
- * Returns reference to the router instance used
4804
- * by the server.
5316
+ * Gets the router instance used for route registration and matching
5317
+ *
5318
+ * @returns The Router instance
4805
5319
  */
4806
5320
  getRouter() {
4807
5321
  return this.#router;
4808
5322
  }
4809
5323
  /**
4810
- * Creates an instance of the [[Request]] class
5324
+ * Creates a Request instance from Node.js request/response objects
5325
+ *
5326
+ * @param req - Node.js IncomingMessage
5327
+ * @param res - Node.js ServerResponse
5328
+ * @returns New Request instance
4811
5329
  */
4812
5330
  createRequest(req, res) {
4813
5331
  return new Request(req, res, this.#encryption, this.#config, this.#qsParser);
4814
5332
  }
4815
5333
  /**
4816
- * Creates an instance of the [[Response]] class
5334
+ * Creates a Response instance from Node.js request/response objects
5335
+ *
5336
+ * @param req - Node.js IncomingMessage
5337
+ * @param res - Node.js ServerResponse
5338
+ * @returns New Response instance
4817
5339
  */
4818
5340
  createResponse(req, res) {
4819
5341
  return new Response(req, res, this.#encryption, this.#config, this.#router, this.#qsParser);
4820
5342
  }
4821
5343
  /**
4822
- * Creates an instance of the [[HttpContext]] class
5344
+ * Creates an HttpContext instance with request-specific logger
5345
+ *
5346
+ * @param request - Request instance
5347
+ * @param response - Response instance
5348
+ * @param resolver - Container resolver for dependency injection
5349
+ * @returns New HttpContext instance
4823
5350
  */
4824
5351
  createHttpContext(request, response, resolver) {
4825
5352
  return new HttpContext(
@@ -4830,13 +5357,19 @@ var Server = class {
4830
5357
  );
4831
5358
  }
4832
5359
  /**
4833
- * Returns a list of server middleware stack
5360
+ * Gets the list of registered global middleware
5361
+ *
5362
+ * @returns Array of parsed global middleware
4834
5363
  */
4835
5364
  getMiddlewareList() {
4836
5365
  return this.#serverMiddlewareStack ? Array.from(this.#serverMiddlewareStack.all()) : [...this.#middleware];
4837
5366
  }
4838
5367
  /**
4839
- * Handle request
5368
+ * Handles an incoming HTTP request by creating context and processing through pipeline
5369
+ *
5370
+ * @param req - Node.js IncomingMessage
5371
+ * @param res - Node.js ServerResponse
5372
+ * @returns Promise that resolves when request processing is complete
4840
5373
  */
4841
5374
  handle(req, res) {
4842
5375
  const hasRequestListener = this.#emitter.hasListeners("http:request_completed");
@@ -4858,10 +5391,22 @@ var Server = class {
4858
5391
  if (this.usingAsyncLocalStorage) {
4859
5392
  return asyncLocalStorage.storage.run(
4860
5393
  ctx,
4861
- () => httpRequest.tracePromise(this.#handleRequest, ctx, this, ctx, resolver)
5394
+ () => httpRequest.tracePromise(
5395
+ this.#handleRequest,
5396
+ httpRequest.hasSubscribers ? { ctx } : void 0,
5397
+ this,
5398
+ ctx,
5399
+ resolver
5400
+ )
4862
5401
  );
4863
5402
  }
4864
- return httpRequest.tracePromise(this.#handleRequest, ctx, this, ctx, resolver);
5403
+ return httpRequest.tracePromise(
5404
+ this.#handleRequest,
5405
+ httpRequest.hasSubscribers ? { ctx } : void 0,
5406
+ this,
5407
+ ctx,
5408
+ resolver
5409
+ );
4865
5410
  }
4866
5411
  };
4867
5412
 
@@ -4928,6 +5473,7 @@ export {
4928
5473
  E_HTTP_REQUEST_ABORTED,
4929
5474
  errors_exports,
4930
5475
  CookieClient,
5476
+ CookieParser,
4931
5477
  canWriteResponseBody,
4932
5478
  tracing_channels_exports,
4933
5479
  Route,
@@ -4938,6 +5484,7 @@ export {
4938
5484
  Request,
4939
5485
  Redirect,
4940
5486
  ResponseStatus,
5487
+ CookieSerializer,
4941
5488
  Response,
4942
5489
  Qs,
4943
5490
  Router,