@adonisjs/http-server 6.8.2-3 → 6.8.2-4

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,5 +1,5 @@
1
- import matchit from '@poppinss/matchit';
2
1
  import { RuntimeException } from '@poppinss/utils';
2
+ import { parseRoutePattern } from '../parser.js';
3
3
  export class UrlBuilder {
4
4
  #qsParser;
5
5
  #params = {};
@@ -28,7 +28,7 @@ export class UrlBuilder {
28
28
  const paramsArray = Array.isArray(this.#params) ? this.#params : null;
29
29
  const paramsObject = !Array.isArray(this.#params) ? this.#params : {};
30
30
  let paramsIndex = 0;
31
- const tokens = matchit.parse(pattern);
31
+ const tokens = parseRoutePattern(pattern);
32
32
  for (const token of tokens) {
33
33
  if (token.type === 0) {
34
34
  uriSegments.push(`${token.val}${token.end}`);
@@ -5,17 +5,18 @@ import { Route } from './route.js';
5
5
  import { RouteGroup } from './group.js';
6
6
  import { BriskRoute } from './brisk.js';
7
7
  import { RouteResource } from './resource.js';
8
- import type { Constructor, LazyImport } from '../types/base.js';
9
8
  import { LookupStore } from './lookup_store/main.js';
10
9
  import { RouteMatchers as Matchers } from './matchers.js';
10
+ import type { Constructor, LazyImport } from '../types/base.js';
11
11
  import type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.js';
12
- import type { RouteFn, MatchedRoute, RouteMatcher, MakeUrlOptions, MakeSignedUrlOptions, GetControllerHandlers } from '../types/route.js';
12
+ import type { RouteFn, MatchedRoute, RouteMatcher, RouteMatchers, MakeUrlOptions, MakeSignedUrlOptions, GetControllerHandlers } from '../types/route.js';
13
13
  export declare class Router extends LookupStore {
14
14
  #private;
15
15
  routes: (Route | RouteResource | RouteGroup | BriskRoute)[];
16
16
  usingDomains: boolean;
17
17
  matchers: Matchers;
18
18
  constructor(app: Application<any>, encryption: Encryption, qsParser: Qs);
19
+ parsePattern(pattern: string, matchers?: RouteMatchers): import("../types/route.js").MatchItRouteToken[];
19
20
  use(middleware: LazyImport<MiddlewareAsClass>[]): this;
20
21
  named<NamedMiddleware extends Record<string, LazyImport<MiddlewareAsClass>>>(collection: NamedMiddleware): { [K in keyof NamedMiddleware]: <Args extends import("../types/middleware.js").GetMiddlewareArgs<import("../types/base.js").UnWrapLazyImport<NamedMiddleware[K]>>>(...args: Args) => {
21
22
  name: K;
@@ -10,6 +10,7 @@ import { RouteResource } from './resource.js';
10
10
  import { LookupStore } from './lookup_store/main.js';
11
11
  import { RouteMatchers as Matchers } from './matchers.js';
12
12
  import { defineNamedMiddleware } from '../define_middleware.js';
13
+ import { parseRoutePattern } from './parser.js';
13
14
  export class Router extends LookupStore {
14
15
  #app;
15
16
  #store = new RoutesStore();
@@ -31,6 +32,9 @@ export class Router extends LookupStore {
31
32
  }
32
33
  this.routes.push(entity);
33
34
  }
35
+ parsePattern(pattern, matchers) {
36
+ return parseRoutePattern(pattern, matchers);
37
+ }
34
38
  use(middleware) {
35
39
  middleware.forEach((one) => this.#middleware.push(moduleImporter(one, 'handle').toHandleMethod()));
36
40
  return this;
@@ -0,0 +1,2 @@
1
+ import { MatchItRouteToken, RouteMatchers } from '../types/route.js';
2
+ export declare function parseRoutePattern(pattern: string, matchers?: RouteMatchers): MatchItRouteToken[];
@@ -0,0 +1,5 @@
1
+ import matchit from '@poppinss/matchit';
2
+ export function parseRoutePattern(pattern, matchers) {
3
+ const tokens = matchit.parse(pattern, matchers);
4
+ return tokens;
5
+ }
@@ -1,12 +1,13 @@
1
1
  import matchit from '@poppinss/matchit';
2
2
  import lodash from '@poppinss/utils/lodash';
3
3
  import { RuntimeException } from '@poppinss/utils';
4
+ import { parseRoutePattern } from './parser.js';
4
5
  export class RoutesStore {
5
6
  usingDomains = false;
6
7
  tree = { tokens: [], domains: {} };
7
8
  #getDomainNode(domain) {
8
9
  if (!this.tree.domains[domain]) {
9
- this.tree.tokens.push(matchit.parse(domain));
10
+ this.tree.tokens.push(parseRoutePattern(domain));
10
11
  this.tree.domains[domain] = {};
11
12
  }
12
13
  return this.tree.domains[domain];
@@ -48,7 +49,7 @@ export class RoutesStore {
48
49
  if (route.domain !== 'root') {
49
50
  this.usingDomains = true;
50
51
  }
51
- const tokens = matchit.parse(route.pattern, route.matchers);
52
+ const tokens = parseRoutePattern(route.pattern, route.matchers);
52
53
  const routeNode = lodash.merge({ meta: {} }, lodash.pick(route, ['pattern', 'handler', 'meta', 'middleware', 'name', 'execute']));
53
54
  routeNode.meta.params = this.#collectRouteParams(routeNode, tokens);
54
55
  route.methods.forEach((method) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonisjs/http-server",
3
- "version": "6.8.2-3",
3
+ "version": "6.8.2-4",
4
4
  "description": "AdonisJS HTTP server with support packed with Routing and Cookies",
5
5
  "main": "build/index.js",
6
6
  "type": "module",