@adonisjs/http-server 8.0.0-next.16 → 8.0.0-next.18

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.
@@ -1,4 +1,4 @@
1
- import { D as __require, E as __export, O as __toESM, T as __commonJSMin, _ as Route, b as httpRequest, d as safeDecodeURI, f as toRoutesJSON, g as BriskRoute, h as RouteResource, l as serializeCookie, m as RouteGroup, n as createSignedURL, o as mime, p as trustProxy, r as encodeUrl, s as parseRoute, v as httpExceptionHandler, w as debug_default, x as httpResponseSerializer, y as httpMiddleware } from "./helpers-oKG4uNSM.js";
1
+ import { D as __require, E as __exportAll, O as __toESM, T as __commonJSMin, _ as Route, b as httpRequest, d as safeDecodeURI, f as toRoutesJSON, g as BriskRoute, h as RouteResource, l as serializeCookie, m as RouteGroup, n as createSignedURL, o as mime$1, p as trustProxy, r as encodeUrl, s as parseRoute, v as httpExceptionHandler, w as debug_default, x as httpResponseSerializer, y as httpMiddleware } from "./helpers-BIq3lNz1.js";
2
2
  import { n as findRoute, t as createURL } from "./helpers-C_2HouOe.js";
3
3
  import { t as createUrlBuilder } from "./url_builder-piNQy-CF.js";
4
4
  import { parse, stringify } from "@poppinss/qs";
@@ -42,7 +42,7 @@ var Qs = class {
42
42
  return stringify(value, this.#config.stringify);
43
43
  };
44
44
  };
45
- var errors_exports = /* @__PURE__ */ __export({
45
+ var errors_exports = /* @__PURE__ */ __exportAll({
46
46
  E_CANNOT_LOOKUP_ROUTE: () => E_CANNOT_LOOKUP_ROUTE,
47
47
  E_HTTP_EXCEPTION: () => E_HTTP_EXCEPTION,
48
48
  E_HTTP_REQUEST_ABORTED: () => E_HTTP_REQUEST_ABORTED,
@@ -158,8 +158,8 @@ var Redirect = class {
158
158
  }
159
159
  };
160
160
  var require_charset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
161
- module.exports = preferredCharsets$1;
162
- module.exports.preferredCharsets = preferredCharsets$1;
161
+ module.exports = preferredCharsets;
162
+ module.exports.preferredCharsets = preferredCharsets;
163
163
  var simpleCharsetRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/;
164
164
  function parseAcceptCharset(accept) {
165
165
  var accepts$1 = accept.split(",");
@@ -198,12 +198,12 @@ var require_charset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
198
198
  s: 0
199
199
  };
200
200
  for (var i = 0; i < accepted.length; i++) {
201
- var spec = specify$3(charset, accepted[i], index);
201
+ var spec = specify(charset, accepted[i], index);
202
202
  if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) priority = spec;
203
203
  }
204
204
  return priority;
205
205
  }
206
- function specify$3(charset, spec, index) {
206
+ function specify(charset, spec, index) {
207
207
  var s = 0;
208
208
  if (spec.charset.toLowerCase() === charset.toLowerCase()) s |= 1;
209
209
  else if (spec.charset !== "*") return null;
@@ -214,29 +214,29 @@ var require_charset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
214
214
  s
215
215
  };
216
216
  }
217
- function preferredCharsets$1(accept, provided) {
217
+ function preferredCharsets(accept, provided) {
218
218
  var accepts$1 = parseAcceptCharset(accept === void 0 ? "*" : accept || "");
219
- if (!provided) return accepts$1.filter(isQuality$3).sort(compareSpecs$3).map(getFullCharset);
219
+ if (!provided) return accepts$1.filter(isQuality).sort(compareSpecs).map(getFullCharset);
220
220
  var priorities = provided.map(function getPriority(type, index) {
221
221
  return getCharsetPriority(type, accepts$1, index);
222
222
  });
223
- return priorities.filter(isQuality$3).sort(compareSpecs$3).map(function getCharset(priority) {
223
+ return priorities.filter(isQuality).sort(compareSpecs).map(function getCharset(priority) {
224
224
  return provided[priorities.indexOf(priority)];
225
225
  });
226
226
  }
227
- function compareSpecs$3(a, b) {
227
+ function compareSpecs(a, b) {
228
228
  return b.q - a.q || b.s - a.s || a.o - b.o || a.i - b.i || 0;
229
229
  }
230
230
  function getFullCharset(spec) {
231
231
  return spec.charset;
232
232
  }
233
- function isQuality$3(spec) {
233
+ function isQuality(spec) {
234
234
  return spec.q > 0;
235
235
  }
236
236
  }));
237
237
  var require_encoding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
238
- module.exports = preferredEncodings$1;
239
- module.exports.preferredEncodings = preferredEncodings$1;
238
+ module.exports = preferredEncodings;
239
+ module.exports.preferredEncodings = preferredEncodings;
240
240
  var simpleEncodingRegExp = /^\s*([^\s;]+)\s*(?:;(.*))?$/;
241
241
  function parseAcceptEncoding(accept) {
242
242
  var accepts$1 = accept.split(",");
@@ -246,7 +246,7 @@ var require_encoding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
246
246
  var encoding = parseEncoding(accepts$1[i].trim(), i);
247
247
  if (encoding) {
248
248
  accepts$1[j++] = encoding;
249
- hasIdentity = hasIdentity || specify$2("identity", encoding);
249
+ hasIdentity = hasIdentity || specify("identity", encoding);
250
250
  minQuality = Math.min(minQuality, encoding.q || 1);
251
251
  }
252
252
  }
@@ -286,12 +286,12 @@ var require_encoding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
286
286
  s: 0
287
287
  };
288
288
  for (var i = 0; i < accepted.length; i++) {
289
- var spec = specify$2(encoding, accepted[i], index);
289
+ var spec = specify(encoding, accepted[i], index);
290
290
  if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) priority = spec;
291
291
  }
292
292
  return priority;
293
293
  }
294
- function specify$2(encoding, spec, index) {
294
+ function specify(encoding, spec, index) {
295
295
  var s = 0;
296
296
  if (spec.encoding.toLowerCase() === encoding.toLowerCase()) s |= 1;
297
297
  else if (spec.encoding !== "*") return null;
@@ -302,29 +302,29 @@ var require_encoding = /* @__PURE__ */ __commonJSMin(((exports, module) => {
302
302
  s
303
303
  };
304
304
  }
305
- function preferredEncodings$1(accept, provided) {
305
+ function preferredEncodings(accept, provided) {
306
306
  var accepts$1 = parseAcceptEncoding(accept || "");
307
- if (!provided) return accepts$1.filter(isQuality$2).sort(compareSpecs$2).map(getFullEncoding);
307
+ if (!provided) return accepts$1.filter(isQuality).sort(compareSpecs).map(getFullEncoding);
308
308
  var priorities = provided.map(function getPriority(type, index) {
309
309
  return getEncodingPriority(type, accepts$1, index);
310
310
  });
311
- return priorities.filter(isQuality$2).sort(compareSpecs$2).map(function getEncoding(priority) {
311
+ return priorities.filter(isQuality).sort(compareSpecs).map(function getEncoding(priority) {
312
312
  return provided[priorities.indexOf(priority)];
313
313
  });
314
314
  }
315
- function compareSpecs$2(a, b) {
315
+ function compareSpecs(a, b) {
316
316
  return b.q - a.q || b.s - a.s || a.o - b.o || a.i - b.i || 0;
317
317
  }
318
318
  function getFullEncoding(spec) {
319
319
  return spec.encoding;
320
320
  }
321
- function isQuality$2(spec) {
321
+ function isQuality(spec) {
322
322
  return spec.q > 0;
323
323
  }
324
324
  }));
325
325
  var require_language = /* @__PURE__ */ __commonJSMin(((exports, module) => {
326
- module.exports = preferredLanguages$1;
327
- module.exports.preferredLanguages = preferredLanguages$1;
326
+ module.exports = preferredLanguages;
327
+ module.exports.preferredLanguages = preferredLanguages;
328
328
  var simpleLanguageRegExp = /^\s*([^\s\-;]+)(?:-([^\s;]+))?\s*(?:;(.*))?$/;
329
329
  function parseAcceptLanguage(accept) {
330
330
  var accepts$1 = accept.split(",");
@@ -365,12 +365,12 @@ var require_language = /* @__PURE__ */ __commonJSMin(((exports, module) => {
365
365
  s: 0
366
366
  };
367
367
  for (var i = 0; i < accepted.length; i++) {
368
- var spec = specify$1(language, accepted[i], index);
368
+ var spec = specify(language, accepted[i], index);
369
369
  if (spec && (priority.s - spec.s || priority.q - spec.q || priority.o - spec.o) < 0) priority = spec;
370
370
  }
371
371
  return priority;
372
372
  }
373
- function specify$1(language, spec, index) {
373
+ function specify(language, spec, index) {
374
374
  var p = parseLanguage(language);
375
375
  if (!p) return null;
376
376
  var s = 0;
@@ -385,29 +385,29 @@ var require_language = /* @__PURE__ */ __commonJSMin(((exports, module) => {
385
385
  s
386
386
  };
387
387
  }
388
- function preferredLanguages$1(accept, provided) {
388
+ function preferredLanguages(accept, provided) {
389
389
  var accepts$1 = parseAcceptLanguage(accept === void 0 ? "*" : accept || "");
390
- if (!provided) return accepts$1.filter(isQuality$1).sort(compareSpecs$1).map(getFullLanguage);
390
+ if (!provided) return accepts$1.filter(isQuality).sort(compareSpecs).map(getFullLanguage);
391
391
  var priorities = provided.map(function getPriority(type, index) {
392
392
  return getLanguagePriority(type, accepts$1, index);
393
393
  });
394
- return priorities.filter(isQuality$1).sort(compareSpecs$1).map(function getLanguage(priority) {
394
+ return priorities.filter(isQuality).sort(compareSpecs).map(function getLanguage(priority) {
395
395
  return provided[priorities.indexOf(priority)];
396
396
  });
397
397
  }
398
- function compareSpecs$1(a, b) {
398
+ function compareSpecs(a, b) {
399
399
  return b.q - a.q || b.s - a.s || a.o - b.o || a.i - b.i || 0;
400
400
  }
401
401
  function getFullLanguage(spec) {
402
402
  return spec.full;
403
403
  }
404
- function isQuality$1(spec) {
404
+ function isQuality(spec) {
405
405
  return spec.q > 0;
406
406
  }
407
407
  }));
408
408
  var require_mediaType = /* @__PURE__ */ __commonJSMin(((exports, module) => {
409
- module.exports = preferredMediaTypes$1;
410
- module.exports.preferredMediaTypes = preferredMediaTypes$1;
409
+ module.exports = preferredMediaTypes;
410
+ module.exports.preferredMediaTypes = preferredMediaTypes;
411
411
  var simpleMediaTypeRegExp = /^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/;
412
412
  function parseAccept(accept) {
413
413
  var accepts$1 = splitMediaTypes(accept);
@@ -479,7 +479,7 @@ var require_mediaType = /* @__PURE__ */ __commonJSMin(((exports, module) => {
479
479
  s
480
480
  };
481
481
  }
482
- function preferredMediaTypes$1(accept, provided) {
482
+ function preferredMediaTypes(accept, provided) {
483
483
  var accepts$1 = parseAccept(accept === void 0 ? "*/*" : accept || "");
484
484
  if (!provided) return accepts$1.filter(isQuality).sort(compareSpecs).map(getFullType);
485
485
  var priorities = provided.map(function getPriority(type, index) {
@@ -546,48 +546,48 @@ var require_negotiator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
546
546
  var preferredEncodings = require_encoding();
547
547
  var preferredLanguages = require_language();
548
548
  var preferredMediaTypes = require_mediaType();
549
- module.exports = Negotiator$1;
550
- module.exports.Negotiator = Negotiator$1;
551
- function Negotiator$1(request) {
552
- if (!(this instanceof Negotiator$1)) return new Negotiator$1(request);
549
+ module.exports = Negotiator;
550
+ module.exports.Negotiator = Negotiator;
551
+ function Negotiator(request) {
552
+ if (!(this instanceof Negotiator)) return new Negotiator(request);
553
553
  this.request = request;
554
554
  }
555
- Negotiator$1.prototype.charset = function charset(available) {
555
+ Negotiator.prototype.charset = function charset(available) {
556
556
  var set = this.charsets(available);
557
557
  return set && set[0];
558
558
  };
559
- Negotiator$1.prototype.charsets = function charsets(available) {
559
+ Negotiator.prototype.charsets = function charsets(available) {
560
560
  return preferredCharsets(this.request.headers["accept-charset"], available);
561
561
  };
562
- Negotiator$1.prototype.encoding = function encoding(available) {
562
+ Negotiator.prototype.encoding = function encoding(available) {
563
563
  var set = this.encodings(available);
564
564
  return set && set[0];
565
565
  };
566
- Negotiator$1.prototype.encodings = function encodings(available) {
566
+ Negotiator.prototype.encodings = function encodings(available) {
567
567
  return preferredEncodings(this.request.headers["accept-encoding"], available);
568
568
  };
569
- Negotiator$1.prototype.language = function language(available) {
569
+ Negotiator.prototype.language = function language(available) {
570
570
  var set = this.languages(available);
571
571
  return set && set[0];
572
572
  };
573
- Negotiator$1.prototype.languages = function languages(available) {
573
+ Negotiator.prototype.languages = function languages(available) {
574
574
  return preferredLanguages(this.request.headers["accept-language"], available);
575
575
  };
576
- Negotiator$1.prototype.mediaType = function mediaType(available) {
576
+ Negotiator.prototype.mediaType = function mediaType(available) {
577
577
  var set = this.mediaTypes(available);
578
578
  return set && set[0];
579
579
  };
580
- Negotiator$1.prototype.mediaTypes = function mediaTypes(available) {
580
+ Negotiator.prototype.mediaTypes = function mediaTypes(available) {
581
581
  return preferredMediaTypes(this.request.headers.accept, available);
582
582
  };
583
- Negotiator$1.prototype.preferredCharset = Negotiator$1.prototype.charset;
584
- Negotiator$1.prototype.preferredCharsets = Negotiator$1.prototype.charsets;
585
- Negotiator$1.prototype.preferredEncoding = Negotiator$1.prototype.encoding;
586
- Negotiator$1.prototype.preferredEncodings = Negotiator$1.prototype.encodings;
587
- Negotiator$1.prototype.preferredLanguage = Negotiator$1.prototype.language;
588
- Negotiator$1.prototype.preferredLanguages = Negotiator$1.prototype.languages;
589
- Negotiator$1.prototype.preferredMediaType = Negotiator$1.prototype.mediaType;
590
- Negotiator$1.prototype.preferredMediaTypes = Negotiator$1.prototype.mediaTypes;
583
+ Negotiator.prototype.preferredCharset = Negotiator.prototype.charset;
584
+ Negotiator.prototype.preferredCharsets = Negotiator.prototype.charsets;
585
+ Negotiator.prototype.preferredEncoding = Negotiator.prototype.encoding;
586
+ Negotiator.prototype.preferredEncodings = Negotiator.prototype.encodings;
587
+ Negotiator.prototype.preferredLanguage = Negotiator.prototype.language;
588
+ Negotiator.prototype.preferredLanguages = Negotiator.prototype.languages;
589
+ Negotiator.prototype.preferredMediaType = Negotiator.prototype.mediaType;
590
+ Negotiator.prototype.preferredMediaTypes = Negotiator.prototype.mediaTypes;
591
591
  }));
592
592
  /*!
593
593
  * accepts
@@ -597,7 +597,7 @@ var require_negotiator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
597
597
  */
598
598
  var require_accepts = /* @__PURE__ */ __commonJSMin(((exports, module) => {
599
599
  var Negotiator = require_negotiator();
600
- var mime$1 = __require("mime-types");
600
+ var mime = __require("mime-types");
601
601
  module.exports = Accepts;
602
602
  function Accepts(req) {
603
603
  if (!(this instanceof Accepts)) return new Accepts(req);
@@ -644,7 +644,7 @@ var require_accepts = /* @__PURE__ */ __commonJSMin(((exports, module) => {
644
644
  return this.negotiator.languages(languages)[0] || false;
645
645
  };
646
646
  function extToMime(type) {
647
- return type.indexOf("/") === -1 ? mime$1.lookup(type) : type;
647
+ return type.indexOf("/") === -1 ? mime.lookup(type) : type;
648
648
  }
649
649
  function validMime(type) {
650
650
  return typeof type === "string";
@@ -730,38 +730,29 @@ var CookieParser = class {
730
730
  if (!cookieHeader) return {};
731
731
  return parse$1(cookieHeader);
732
732
  }
733
- decode(key, stringified = true) {
733
+ #getCachedOrParse(key, cacheKey, parser) {
734
734
  const value = this.#cookies[key];
735
735
  if (value === null || value === void 0) return null;
736
- const cache = this.#cachedCookies.plainCookies;
736
+ const cache = this.#cachedCookies[cacheKey];
737
737
  if (cache[key] !== void 0) return cache[key];
738
- const parsed = this.#client.decode(key, value, stringified);
738
+ const parsed = parser(value);
739
739
  if (parsed !== null) cache[key] = parsed;
740
740
  return parsed;
741
741
  }
742
+ decode(key, stringified = true) {
743
+ return this.#getCachedOrParse(key, "plainCookies", (value) => this.#client.decode(key, value, stringified));
744
+ }
742
745
  unsign(key) {
743
- const value = this.#cookies[key];
744
- if (value === null || value === void 0) return null;
745
- const cache = this.#cachedCookies.signedCookies;
746
- if (cache[key] !== void 0) return cache[key];
747
- const parsed = this.#client.unsign(key, value);
748
- if (parsed !== null) cache[key] = parsed;
749
- return parsed;
746
+ return this.#getCachedOrParse(key, "signedCookies", (value) => this.#client.unsign(key, value));
750
747
  }
751
748
  decrypt(key) {
752
- const value = this.#cookies[key];
753
- if (value === null || value === void 0) return null;
754
- const cache = this.#cachedCookies.encryptedCookies;
755
- if (cache[key] !== void 0) return cache[key];
756
- const parsed = this.#client.decrypt(key, value);
757
- if (parsed !== null) cache[key] = parsed;
758
- return parsed;
749
+ return this.#getCachedOrParse(key, "encryptedCookies", (value) => this.#client.decrypt(key, value));
759
750
  }
760
751
  list() {
761
752
  return this.#cookies;
762
753
  }
763
754
  };
764
- var import_accepts = /* @__PURE__ */ __toESM(require_accepts(), 1);
755
+ var import_accepts = /* @__PURE__ */ __toESM(require_accepts());
765
756
  var HttpRequest = class extends Macroable {
766
757
  #qsParser;
767
758
  #encryption;
@@ -977,7 +968,7 @@ var HttpRequest = class extends Macroable {
977
968
  return typeIs.hasBody(this.request);
978
969
  }
979
970
  fresh() {
980
- if (["GET", "HEAD"].indexOf(this.intended()) === -1) return false;
971
+ if (!["GET", "HEAD"].includes(this.intended())) return false;
981
972
  const status = this.response.statusCode;
982
973
  if (status >= 200 && status < 300 || status === 304) return fresh(this.headers(), this.response.getHeaders());
983
974
  return false;
@@ -1867,7 +1858,7 @@ var HttpResponse = class extends Macroable {
1867
1858
  }
1868
1859
  type(type, charset) {
1869
1860
  type = charset ? `${type}; charset=${charset}` : type;
1870
- this.header("Content-Type", mime.contentType(type));
1861
+ this.header("Content-Type", mime$1.contentType(type));
1871
1862
  return this;
1872
1863
  }
1873
1864
  vary(field) {
@@ -2268,8 +2259,8 @@ var Server = class {
2268
2259
  #router;
2269
2260
  #nodeHttpServer;
2270
2261
  #middleware = [];
2271
- #requestErrorResponder = (error, ctx) => {
2272
- this.#resolvedErrorHandler.report(error, ctx);
2262
+ #requestErrorResponder = async (error, ctx) => {
2263
+ await this.#resolvedErrorHandler.report(error, ctx);
2273
2264
  return httpExceptionHandler.tracePromise(this.#resolvedErrorHandler.handle, void 0, this.#resolvedErrorHandler, error, ctx);
2274
2265
  };
2275
2266
  get booted() {
@@ -6,6 +6,12 @@ type FactoryParameters = {
6
6
  request: HttpRequest;
7
7
  response: HttpResponse;
8
8
  logger: Logger;
9
+ url?: string;
10
+ method?: string;
11
+ route?: {
12
+ pattern: string;
13
+ params: Record<string, any>;
14
+ };
9
15
  };
10
16
  /**
11
17
  * HttpContext factory is used to generate Http context class instances for
@@ -1,6 +1,6 @@
1
- import "../helpers-oKG4uNSM.js";
2
- import { _ as Qs, c as HttpRequest, i as HttpResponse, n as Server, r as HttpContext, s as Router, t as defineConfig } from "../define_config-Dh5SpqNg.js";
3
- import "../helpers-C_2HouOe.js";
1
+ import { s as parseRoute } from "../helpers-BIq3lNz1.js";
2
+ import { _ as Qs, c as HttpRequest, i as HttpResponse, n as Server, r as HttpContext, s as Router, t as defineConfig } from "../define_config-Cg6Nym29.js";
3
+ import { t as createURL } from "../helpers-C_2HouOe.js";
4
4
  import "../url_builder-piNQy-CF.js";
5
5
  import { Container } from "@adonisjs/fold";
6
6
  import { Socket } from "node:net";
@@ -155,7 +155,13 @@ var ServerFactory = class {
155
155
  var HttpContextFactory = class {
156
156
  #parameters = {};
157
157
  #createRequest() {
158
- return this.#parameters.request || new HttpRequestFactory().create();
158
+ if (this.#parameters.request) return this.#parameters.request;
159
+ let { url, method, route } = this.#parameters;
160
+ if (route) url = createURL(route.pattern, parseRoute(route.pattern), new QsParserFactory().create().stringify, route.params);
161
+ return new HttpRequestFactory().merge({
162
+ url,
163
+ method
164
+ }).create();
159
165
  }
160
166
  #createResponse() {
161
167
  return this.#parameters.response || new HttpResponseFactory().create();
@@ -21,7 +21,7 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
21
21
  var __getProtoOf = Object.getPrototypeOf;
22
22
  var __hasOwnProp = Object.prototype.hasOwnProperty;
23
23
  var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
24
- var __export = (all, symbols) => {
24
+ var __exportAll = (all, symbols) => {
25
25
  let target = {};
26
26
  for (var name in all) __defProp(target, name, {
27
27
  get: all[name],
@@ -54,7 +54,7 @@ function useReturnValue(ctx) {
54
54
  if (canWriteResponseBody(value, ctx)) ctx.response.send(value);
55
55
  };
56
56
  }
57
- var tracing_channels_exports = /* @__PURE__ */ __export({
57
+ var tracing_channels_exports = /* @__PURE__ */ __exportAll({
58
58
  httpExceptionHandler: () => httpExceptionHandler,
59
59
  httpMiddleware: () => httpMiddleware,
60
60
  httpRequest: () => httpRequest,
@@ -155,6 +155,9 @@ var Route = class extends Macroable {
155
155
  const prefix = this.#prefixes.slice().reverse().map((one) => dropSlash(one)).join("");
156
156
  return prefix ? `${prefix}${pattern === "/" ? "" : pattern}` : pattern;
157
157
  }
158
+ getHandler() {
159
+ return this.#handler;
160
+ }
158
161
  where(param, matcher) {
159
162
  if (this.#matchers[param]) return this;
160
163
  if (typeof matcher === "string") this.#matchers[param] = { match: new RegExp(matcher) };
@@ -683,4 +686,4 @@ function appendQueryString(uri, queryString, qsParser) {
683
686
  const mergedQueryString = qsParser.stringify(Object.assign(qsParser.parse(query), queryString));
684
687
  return mergedQueryString ? `${pathname}?${mergedQueryString}` : pathname;
685
688
  }
686
- export { canWriteResponseBody as C, __require as D, __export as E, __toESM as O, tracing_channels_exports as S, __commonJSMin as T, Route as _, middlewareInfo as a, httpRequest as b, routeInfo as c, safeDecodeURI as d, toRoutesJSON as f, BriskRoute as g, RouteResource as h, matchRoute as i, serializeCookie as l, RouteGroup as m, createSignedURL as n, mime as o, trustProxy as p, encodeUrl as r, parseRoute as s, appendQueryString as t, parseRange as u, httpExceptionHandler as v, debug_default as w, httpResponseSerializer as x, httpMiddleware as y };
689
+ export { canWriteResponseBody as C, __require as D, __exportAll as E, __toESM as O, tracing_channels_exports as S, __commonJSMin as T, Route as _, middlewareInfo as a, httpRequest as b, routeInfo as c, safeDecodeURI as d, toRoutesJSON as f, BriskRoute as g, RouteResource as h, matchRoute as i, serializeCookie as l, RouteGroup as m, createSignedURL as n, mime as o, trustProxy as p, encodeUrl as r, parseRoute as s, appendQueryString as t, parseRange as u, httpExceptionHandler as v, debug_default as w, httpResponseSerializer as x, httpMiddleware as y };
package/build/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { C as canWriteResponseBody, S as tracing_channels_exports, _ as Route, g as BriskRoute, h as RouteResource, m as RouteGroup, u as parseRange } from "./helpers-oKG4uNSM.js";
2
- import { _ as Qs, a as CookieSerializer, c as HttpRequest, d as Redirect, f as E_CANNOT_LOOKUP_ROUTE, g as errors_exports, h as E_ROUTE_NOT_FOUND, i as HttpResponse, l as CookieParser, m as E_HTTP_REQUEST_ABORTED, n as Server, o as ResponseStatus, p as E_HTTP_EXCEPTION, r as HttpContext, s as Router, t as defineConfig, u as CookieClient } from "./define_config-Dh5SpqNg.js";
1
+ import { C as canWriteResponseBody, S as tracing_channels_exports, _ as Route, g as BriskRoute, h as RouteResource, m as RouteGroup, u as parseRange } from "./helpers-BIq3lNz1.js";
2
+ import { _ as Qs, a as CookieSerializer, c as HttpRequest, d as Redirect, f as E_CANNOT_LOOKUP_ROUTE, g as errors_exports, h as E_ROUTE_NOT_FOUND, i as HttpResponse, l as CookieParser, m as E_HTTP_REQUEST_ABORTED, n as Server, o as ResponseStatus, p as E_HTTP_EXCEPTION, r as HttpContext, s as Router, t as defineConfig, u as CookieClient } from "./define_config-Cg6Nym29.js";
3
3
  import "./helpers-C_2HouOe.js";
4
4
  import "./url_builder-piNQy-CF.js";
5
5
  import Macroable from "@poppinss/macroable";
@@ -31,7 +31,7 @@ export declare class CookieSerializer {
31
31
  */
32
32
  encode(key: string, value: any, options?: Partial<CookieOptions & {
33
33
  /**
34
- * @depreacted Instead use stringify option
34
+ * @deprecated Instead use stringify option
35
35
  */
36
36
  encode: boolean;
37
37
  stringify: boolean;
@@ -1,3 +1,3 @@
1
- import { a as middlewareInfo, c as routeInfo, i as matchRoute, l as serializeCookie, n as createSignedURL, o as mime, r as encodeUrl, s as parseRoute, t as appendQueryString } from "../helpers-oKG4uNSM.js";
1
+ import { a as middlewareInfo, c as routeInfo, i as matchRoute, l as serializeCookie, n as createSignedURL, o as mime, r as encodeUrl, s as parseRoute, t as appendQueryString } from "../helpers-BIq3lNz1.js";
2
2
  import { t as createURL } from "../helpers-C_2HouOe.js";
3
3
  export { appendQueryString, createSignedURL, createURL, encodeUrl, matchRoute, middlewareInfo, mime, parseRoute, routeInfo, serializeCookie };
@@ -2,7 +2,7 @@ import Macroable from '@poppinss/macroable';
2
2
  import type { Application } from '@adonisjs/application';
3
3
  import type { Constructor, LazyImport, OneOrMore } from '@poppinss/utils/types';
4
4
  import type { MiddlewareFn, ParsedNamedMiddleware, ParsedGlobalMiddleware } from '../types/middleware.ts';
5
- import type { RouteFn, RouteJSON, RouteMatcher, RouteMatchers, StoreRouteMiddleware, GetControllerHandlers } from '../types/route.ts';
5
+ import type { RouteFn, RouteJSON, RouteMatcher, RouteMatchers, StoreRouteHandler, StoreRouteMiddleware, GetControllerHandlers } from '../types/route.ts';
6
6
  /**
7
7
  * The Route class provides a fluent API for constructing and configuring HTTP routes.
8
8
  *
@@ -39,79 +39,160 @@ export declare class Route<Controller extends Constructor<any> = any> extends Ma
39
39
  globalMatchers: RouteMatchers;
40
40
  });
41
41
  /**
42
- * Define matcher for a given param. If a matcher exists, then we do not
43
- * override that, since the routes inside a group will set matchers
44
- * before the group, so they should have priority over the group
45
- * matchers.
42
+ * Returns the route's handler configuration object.
43
+ */
44
+ getHandler(): StoreRouteHandler;
45
+ /**
46
+ * Defines a validation matcher for a route parameter. Route-level matchers
47
+ * take precedence over group-level matchers to ensure routes can override
48
+ * group constraints.
49
+ *
50
+ * @param param - The name of the route parameter to validate
51
+ * @param matcher - The validation pattern as a string, RegExp, or RouteMatcher object
46
52
  *
53
+ * @example
47
54
  * ```ts
55
+ * // Validate that 'id' is numeric
56
+ * route.where('id', /^[0-9]+$/)
57
+ *
58
+ * // Using a string pattern
59
+ * route.where('slug', '[a-z0-9-]+')
60
+ *
61
+ * // Route matcher takes precedence over group matcher
48
62
  * Route.group(() => {
49
63
  * Route.get('/:id', 'handler').where('id', /^[0-9]$/)
50
64
  * }).where('id', /[^a-z$]/)
65
+ * // The route's /^[0-9]$/ wins over the group's matcher
51
66
  * ```
52
- *
53
- * The `/^[0-9]$/` will win over the matcher defined by the group
54
67
  */
55
68
  where(param: string, matcher: RouteMatcher | string | RegExp): this;
56
69
  /**
57
- * Define prefix for the route. Calling this method multiple times
58
- * applies multiple prefixes in the reverse order.
59
- * @param prefix - The prefix to add to the route
60
- * @returns Current Route instance for method chaining
70
+ * Adds a URL prefix to the route pattern. Multiple calls stack prefixes
71
+ * which are applied in reverse order during pattern computation.
72
+ *
73
+ * @param prefix - The URL prefix to prepend to the route pattern
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * route.prefix('/api').prefix('/v1')
78
+ * // Results in pattern: /v1/api/users (for original pattern /users)
79
+ * ```
61
80
  */
62
81
  prefix(prefix: string): this;
63
82
  /**
64
- * Define a custom domain for the route. We do not overwrite the domain
65
- * unless `overwrite` flag is set to true.
83
+ * Assigns a custom domain to the route. By default, routes belong to the
84
+ * 'root' domain. Once set, the domain is not overwritten unless the
85
+ * overwrite flag is true.
86
+ *
87
+ * @param domain - The domain identifier for this route
88
+ * @param overwrite - Whether to overwrite an existing non-root domain
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * route.domain('api.example.com')
93
+ *
94
+ * // Overwrite existing domain
95
+ * route.domain('new.example.com', true)
96
+ * ```
66
97
  */
67
98
  domain(domain: string, overwrite?: boolean): this;
68
99
  /**
69
- * Define one or more middleware to be executed before the route
70
- * handler.
100
+ * Registers one or more middleware to execute before the route handler.
101
+ * Middleware can be inline functions or named middleware references registered
102
+ * with the router's middleware store.
103
+ *
104
+ * @param middleware - Single middleware or array of middleware to apply
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * // Single middleware
109
+ * route.use(async (ctx, next) => {
110
+ * console.log('Before handler')
111
+ * await next()
112
+ * })
71
113
  *
72
- * Named middleware can be referenced using the name registered with
73
- * the router middleware store.
114
+ * // Multiple middleware
115
+ * route.use(['auth', 'admin'])
116
+ * ```
74
117
  */
75
118
  use(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this;
76
119
  /**
77
- * Alias for {@link Route.use}
120
+ * Alias for the {@link Route.use} method.
121
+ *
122
+ * @param middleware - Single middleware or array of middleware to apply
78
123
  */
79
124
  middleware(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this;
80
125
  /**
81
- * Give a unique name to the route. Assinging a new unique removes the
82
- * existing name of the route.
126
+ * Assigns a unique name to the route for use in URL generation and route
127
+ * referencing. Assigning a new name replaces any existing name unless
128
+ * prepend is true.
83
129
  *
84
- * Setting prepends to true prefixes the name to the existing name.
130
+ * @param name - The route name to assign
131
+ * @param prepend - If true, prepends the name to the existing name with a dot separator
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * // Set route name
136
+ * route.as('users.show')
137
+ *
138
+ * // Prepend to existing name (typically used by route groups)
139
+ * route.as('admin', true) // Results in 'admin.users.show'
140
+ * ```
85
141
  */
86
142
  as(name: string, prepend?: boolean): this;
87
143
  /**
88
- * Check if the route was marked to be deleted
144
+ * Checks whether the route has been marked for deletion. Deleted routes
145
+ * are excluded from the route store during registration.
89
146
  */
90
147
  isDeleted(): boolean;
91
148
  /**
92
- * Mark route as deleted. Deleted routes are not registered
93
- * with the route store
149
+ * Marks the route for deletion. Deleted routes will not be registered
150
+ * with the route store when Router.commit() is called.
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * const route = Route.get('/admin', 'handler')
155
+ * route.markAsDeleted()
156
+ * // This route will not be registered
157
+ * ```
94
158
  */
95
159
  markAsDeleted(): void;
96
160
  /**
97
- * Get the route name
161
+ * Returns the unique name assigned to the route, if any.
98
162
  */
99
163
  getName(): string | undefined;
100
164
  /**
101
- * Get the route pattern
165
+ * Returns the route's URL pattern with dynamic parameters.
102
166
  */
103
167
  getPattern(): string;
104
168
  /**
105
- * Set the route pattern
169
+ * Updates the route's URL pattern.
170
+ *
171
+ * @param pattern - The new URL pattern to assign to the route
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * route.setPattern('/users/:id/posts/:postId')
176
+ * ```
106
177
  */
107
178
  setPattern(pattern: string): this;
108
179
  /**
109
- * Returns the stack of middleware registered on the route.
110
- * The value is shared by reference.
180
+ * Returns the multi-dimensional middleware stack registered on this route.
181
+ * The returned value is shared by reference, not a copy.
111
182
  */
112
183
  getMiddleware(): StoreRouteMiddleware[][];
113
184
  /**
114
- * Returns JSON representation of the route
185
+ * Serializes the route into a JSON representation suitable for storage and
186
+ * execution. This includes the computed pattern with prefixes, merged matchers,
187
+ * parsed route tokens, and frozen middleware stack.
188
+ *
189
+ * @example
190
+ * ```ts
191
+ * const json = route.toJSON()
192
+ * console.log(json.pattern) // '/api/users/:id'
193
+ * console.log(json.methods) // ['GET']
194
+ * console.log(json.name) // 'users.show'
195
+ * ```
115
196
  */
116
197
  toJSON(): RouteJSON;
117
198
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonisjs/http-server",
3
- "version": "8.0.0-next.16",
3
+ "version": "8.0.0-next.18",
4
4
  "description": "AdonisJS HTTP server with support packed with Routing and Cookies",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
@@ -43,22 +43,22 @@
43
43
  "author": "virk,adonisjs",
44
44
  "license": "MIT",
45
45
  "devDependencies": {
46
- "@adonisjs/application": "^9.0.0-next.12",
46
+ "@adonisjs/application": "^9.0.0-next.14",
47
47
  "@adonisjs/eslint-config": "^3.0.0-next.1",
48
- "@adonisjs/events": "^10.1.0-next.3",
49
- "@adonisjs/fold": "^11.0.0-next.3",
48
+ "@adonisjs/events": "^10.1.0-next.4",
49
+ "@adonisjs/fold": "^11.0.0-next.4",
50
50
  "@adonisjs/logger": "^7.1.0-next.3",
51
51
  "@adonisjs/prettier-config": "^1.4.5",
52
- "@adonisjs/tsconfig": "^2.0.0-next.0",
53
- "@boringnode/encryption": "^0.2.2",
54
- "@fastify/middie": "^9.0.3",
55
- "@japa/assert": "^4.1.1",
56
- "@japa/expect-type": "^2.0.3",
57
- "@japa/file-system": "^2.3.2",
58
- "@japa/runner": "^4.4.0",
59
- "@japa/snapshot": "^2.0.9",
52
+ "@adonisjs/tsconfig": "^2.0.0-next.3",
53
+ "@boringnode/encryption": "^0.2.4",
54
+ "@fastify/middie": "^9.1.0",
55
+ "@japa/assert": "^4.2.0",
56
+ "@japa/expect-type": "^2.0.4",
57
+ "@japa/file-system": "^3.0.0",
58
+ "@japa/runner": "^5.0.0",
59
+ "@japa/snapshot": "^2.0.10",
60
60
  "@poppinss/ts-exec": "^1.4.1",
61
- "@release-it/conventional-changelog": "^10.0.3",
61
+ "@release-it/conventional-changelog": "^10.0.4",
62
62
  "@types/accepts": "^1.3.7",
63
63
  "@types/content-disposition": "^0.5.9",
64
64
  "@types/destroy": "^1.0.3",
@@ -67,7 +67,7 @@
67
67
  "@types/fresh": "^0.5.3",
68
68
  "@types/fs-extra": "^11.0.4",
69
69
  "@types/mime-types": "^3.0.1",
70
- "@types/node": "^25.0.0",
70
+ "@types/node": "^25.0.3",
71
71
  "@types/on-finished": "^2.3.5",
72
72
  "@types/pem": "^1.14.4",
73
73
  "@types/proxy-addr": "^2.0.3",
@@ -79,17 +79,17 @@
79
79
  "autocannon": "^8.0.0",
80
80
  "c8": "^10.1.3",
81
81
  "cross-env": "^10.1.0",
82
- "eslint": "^9.39.1",
82
+ "eslint": "^9.39.2",
83
83
  "fastify": "^5.6.2",
84
- "fs-extra": "^11.3.2",
84
+ "fs-extra": "^11.3.3",
85
85
  "get-port": "^7.1.0",
86
86
  "http-status-codes": "^2.3.0",
87
87
  "pem": "^1.14.8",
88
88
  "prettier": "^3.7.4",
89
89
  "reflect-metadata": "^0.2.2",
90
- "release-it": "^19.1.0",
91
- "supertest": "^7.1.4",
92
- "tsdown": "^0.17.2",
90
+ "release-it": "^19.2.3",
91
+ "supertest": "^7.2.2",
92
+ "tsdown": "^0.18.4",
93
93
  "typedoc": "^0.28.15",
94
94
  "typescript": "^5.9.3",
95
95
  "youch": "^4.1.0-beta.13"
@@ -97,10 +97,10 @@
97
97
  "dependencies": {
98
98
  "@poppinss/macroable": "^1.1.0",
99
99
  "@poppinss/matchit": "^3.2.0",
100
- "@poppinss/middleware": "^3.2.6",
100
+ "@poppinss/middleware": "^3.2.7",
101
101
  "@poppinss/qs": "^6.15.0",
102
102
  "@poppinss/utils": "^7.0.0-next.4",
103
- "@sindresorhus/is": "^7.1.1",
103
+ "@sindresorhus/is": "^7.2.0",
104
104
  "content-disposition": "^1.0.1",
105
105
  "cookie-es": "^2.0.0",
106
106
  "destroy": "^1.2.0",
@@ -115,9 +115,9 @@
115
115
  "vary": "^1.1.2"
116
116
  },
117
117
  "peerDependencies": {
118
- "@adonisjs/application": "^9.0.0-next.12",
119
- "@adonisjs/events": "^10.1.0-next.3",
120
- "@adonisjs/fold": "^11.0.0-next.3",
118
+ "@adonisjs/application": "^9.0.0-next.14",
119
+ "@adonisjs/events": "^10.1.0-next.4",
120
+ "@adonisjs/fold": "^11.0.0-next.4",
121
121
  "@adonisjs/logger": "^7.1.0-next.3",
122
122
  "@boringnode/encryption": "^0.2.2",
123
123
  "youch": "^4.1.0-beta.13"