@adonisjs/http-server 8.0.0-next.0 → 8.0.0-next.10

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 (74) hide show
  1. package/build/chunk-2QM3D5BN.js +87 -0
  2. package/build/chunk-5PWHBE2E.js +128 -0
  3. package/build/chunk-QDK57QGB.js +1176 -0
  4. package/build/{chunk-VYBTM3NC.js → chunk-YBLFT4O6.js} +1161 -1719
  5. package/build/factories/http_context.d.ts +5 -4
  6. package/build/factories/http_server.d.ts +7 -0
  7. package/build/factories/main.d.ts +6 -6
  8. package/build/factories/main.js +33 -5
  9. package/build/factories/qs_parser_factory.d.ts +5 -4
  10. package/build/factories/request.d.ts +3 -2
  11. package/build/factories/response.d.ts +4 -3
  12. package/build/factories/router.d.ts +2 -1
  13. package/build/factories/server_factory.d.ts +3 -2
  14. package/build/factories/url_builder_factory.d.ts +3 -2
  15. package/build/index.d.ts +19 -16
  16. package/build/index.js +97 -42
  17. package/build/src/client/helpers.d.ts +37 -0
  18. package/build/src/client/types.d.ts +88 -66
  19. package/build/src/client/url_builder.d.ts +12 -10
  20. package/build/src/client/url_builder.js +12 -0
  21. package/build/src/cookies/client.d.ts +61 -3
  22. package/build/src/cookies/drivers/encrypted.d.ts +13 -0
  23. package/build/src/cookies/drivers/plain.d.ts +9 -0
  24. package/build/src/cookies/drivers/signed.d.ts +13 -0
  25. package/build/src/cookies/parser.d.ts +18 -0
  26. package/build/src/cookies/serializer.d.ts +22 -3
  27. package/build/src/debug.d.ts +13 -0
  28. package/build/src/define_config.d.ts +21 -5
  29. package/build/src/define_middleware.d.ts +20 -4
  30. package/build/src/errors.d.ts +67 -10
  31. package/build/src/exception_handler.d.ts +95 -41
  32. package/build/src/helpers.d.ts +60 -4
  33. package/build/src/helpers.js +9 -1
  34. package/build/src/http_context/local_storage.d.ts +18 -1
  35. package/build/src/http_context/main.d.ts +71 -13
  36. package/build/src/qs.d.ts +31 -3
  37. package/build/src/redirect.d.ts +87 -16
  38. package/build/src/request.d.ts +121 -15
  39. package/build/src/response.d.ts +421 -208
  40. package/build/src/response_status.d.ts +14 -0
  41. package/build/src/router/brisk.d.ts +18 -7
  42. package/build/src/router/executor.d.ts +7 -3
  43. package/build/src/router/factories/use_return_value.d.ts +6 -1
  44. package/build/src/router/group.d.ts +23 -6
  45. package/build/src/router/legacy/url_builder.d.ts +15 -15
  46. package/build/src/router/main.d.ts +133 -20
  47. package/build/src/router/matchers.d.ts +3 -0
  48. package/build/src/router/resource.d.ts +37 -5
  49. package/build/src/router/route.d.ts +30 -6
  50. package/build/src/router/signed_url_builder.d.ts +7 -10
  51. package/build/src/router/store.d.ts +10 -2
  52. package/build/src/server/factories/middleware_handler.d.ts +12 -3
  53. package/build/src/server/factories/route_finder.d.ts +16 -6
  54. package/build/src/server/factories/write_response.d.ts +10 -3
  55. package/build/src/server/main.d.ts +83 -29
  56. package/build/src/tracing_channels.d.ts +4 -4
  57. package/build/src/types/main.d.ts +1 -1
  58. package/build/src/types/middleware.d.ts +35 -10
  59. package/build/src/types/qs.d.ts +5 -0
  60. package/build/src/types/request.d.ts +1 -1
  61. package/build/src/types/response.d.ts +14 -6
  62. package/build/src/types/route.d.ts +53 -51
  63. package/build/src/types/server.d.ts +30 -15
  64. package/build/src/types/tracing_channels.d.ts +24 -6
  65. package/build/src/types/url_builder.d.ts +22 -0
  66. package/build/src/utils.d.ts +76 -11
  67. package/package.json +29 -30
  68. package/build/chunk-ASX56VAK.js +0 -76
  69. package/build/client.cjs +0 -232
  70. package/build/client.d.cts +0 -258
  71. package/build/client.d.ts +0 -258
  72. package/build/client.js +0 -229
  73. package/build/src/client/main.d.ts +0 -3
  74. package/build/src/client/router.d.ts +0 -68
@@ -1,3 +1,17 @@
1
+ /**
2
+ * Standard HTTP response status codes organized as a constant object.
3
+ *
4
+ * This object provides named constants for all standard HTTP status codes,
5
+ * making code more readable and less error-prone when setting response statuses.
6
+ * The naming follows PascalCase convention for consistency with TypeScript conventions.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * response.status(ResponseStatus.NotFound)
11
+ * response.status(ResponseStatus.InternalServerError)
12
+ * response.status(ResponseStatus.Created)
13
+ * ```
14
+ */
1
15
  export declare const ResponseStatus: {
2
16
  readonly Continue: 100;
3
17
  readonly SwitchingProtocols: 101;
@@ -1,9 +1,9 @@
1
1
  import Macroable from '@poppinss/macroable';
2
2
  import type { Application } from '@adonisjs/application';
3
- import { Route } from './route.js';
4
- import type { ParsedGlobalMiddleware } from '../types/middleware.js';
5
- import type { RouteBuilderArguments, URLOptions } from '../client/types.ts';
6
- import type { GetRoutesForMethod, RouteFn, RouteMatchers, RoutesList } from '../types/route.js';
3
+ import { Route } from './route.ts';
4
+ import type { RouteFn, RouteMatchers } from '../types/route.ts';
5
+ import type { ParsedGlobalMiddleware } from '../types/middleware.ts';
6
+ import type { RoutesList, LookupList, URLOptions, GetRoutesForMethod, RouteBuilderArguments } from '../types/url_builder.ts';
7
7
  /**
8
8
  * Brisk routes exposes the API to configure the route handler by chaining
9
9
  * one of the pre-defined methods.
@@ -19,23 +19,34 @@ export declare class BriskRoute extends Macroable {
19
19
  * Reference to route instance. Set after `setHandler` is called
20
20
  */
21
21
  route: null | Route;
22
+ /**
23
+ * Creates a new BriskRoute instance
24
+ * @param app - The AdonisJS application instance
25
+ * @param routerMiddleware - Array of global middleware registered on the router
26
+ * @param options - Configuration options for the brisk route
27
+ */
22
28
  constructor(app: Application<any>, routerMiddleware: ParsedGlobalMiddleware[], options: {
23
29
  pattern: string;
24
30
  globalMatchers: RouteMatchers;
25
31
  });
26
32
  /**
27
33
  * Set handler for the brisk route
34
+ * @param handler - The route handler function
35
+ * @returns The created route instance
28
36
  */
29
37
  setHandler(handler: RouteFn): Route;
30
38
  /**
31
39
  * Redirects to a given route. Params from the original request will
32
40
  * be used when no custom params are defined.
41
+ * @param args - Route identifier, parameters, and options for building the redirect URL
42
+ * @returns The created route instance
33
43
  */
34
- redirect<Identifier extends keyof GetRoutesForMethod<'GET'> & string>(...args: RouteBuilderArguments<RoutesList, Identifier, 'GET', URLOptions & {
35
- status: number;
36
- }>): Route;
44
+ redirect<Identifier extends keyof GetRoutesForMethod<RoutesList, 'GET'> & string>(...args: RoutesList extends LookupList ? RouteBuilderArguments<Identifier, RoutesList['GET'][Identifier], URLOptions> : []): Route;
37
45
  /**
38
46
  * Redirect request to a fixed URL
47
+ * @param url - The URL to redirect to
48
+ * @param options - Optional redirect options including HTTP status code
49
+ * @returns The created route instance
39
50
  */
40
51
  redirectToPath(url: string, options?: {
41
52
  status: number;
@@ -1,9 +1,13 @@
1
1
  import type { ContainerResolver } from '@adonisjs/fold';
2
- import type { RouteJSON } from '../types/route.js';
3
- import type { HttpContext } from '../http_context/main.js';
4
- import type { ServerErrorHandler } from '../types/server.js';
2
+ import type { RouteJSON } from '../types/route.ts';
3
+ import type { HttpContext } from '../http_context/main.ts';
4
+ import type { ServerErrorHandler } from '../types/server.ts';
5
5
  /**
6
6
  * Executor to execute the route middleware pipeline the route
7
7
  * handler
8
+ * @param route - The route JSON object containing route information
9
+ * @param resolver - Container resolver for dependency injection
10
+ * @param ctx - The HTTP context instance
11
+ * @param errorResponder - Error handler function for handling errors
8
12
  */
9
13
  export declare function execute(route: RouteJSON, resolver: ContainerResolver<any>, ctx: HttpContext, errorResponder: ServerErrorHandler['handle']): Promise<void>;
@@ -1,11 +1,16 @@
1
- import { type HttpContext } from '../../http_context/main.js';
1
+ import { type HttpContext } from '../../http_context/main.ts';
2
2
  /**
3
3
  * Check if the value can be used to write the response body. Returns
4
4
  * false when the response body has already been set
5
+ * @param value - The value to check
6
+ * @param ctx - The HTTP context instance
7
+ * @returns True if value can be used for response body
5
8
  */
6
9
  export declare function canWriteResponseBody(value: any, ctx: HttpContext): boolean;
7
10
  /**
8
11
  * A factory function that uses the return value of the request
9
12
  * pipeline as the response
13
+ * @param ctx - The HTTP context instance
14
+ * @returns Function that handles return values
10
15
  */
11
16
  export declare function useReturnValue(ctx: HttpContext): (value: any) => void;
@@ -1,10 +1,10 @@
1
1
  import Macroable from '@poppinss/macroable';
2
2
  import type { OneOrMore } from '@poppinss/utils/types';
3
- import { type Route } from './route.js';
4
- import { BriskRoute } from './brisk.js';
5
- import { RouteResource } from './resource.js';
6
- import type { RouteMatcher } from '../client/types.ts';
7
- import type { MiddlewareFn, ParsedNamedMiddleware } from '../types/middleware.js';
3
+ import { type Route } from './route.ts';
4
+ import { BriskRoute } from './brisk.ts';
5
+ import { RouteResource } from './resource.ts';
6
+ import { type RouteMatcher } from '../types/route.ts';
7
+ import type { MiddlewareFn, ParsedNamedMiddleware } from '../types/middleware.ts';
8
8
  /**
9
9
  * Group class exposes the API to take action on a group of routes.
10
10
  * The group routes must be pre-defined using the constructor.
@@ -12,6 +12,10 @@ import type { MiddlewareFn, ParsedNamedMiddleware } from '../types/middleware.js
12
12
  export declare class RouteGroup extends Macroable {
13
13
  #private;
14
14
  routes: (Route | RouteGroup | RouteResource | BriskRoute)[];
15
+ /**
16
+ * Creates a new RouteGroup instance
17
+ * @param routes - Array of routes that belong to this group
18
+ */
15
19
  constructor(routes: (Route | RouteGroup | RouteResource | BriskRoute)[]);
16
20
  /**
17
21
  * Define route param matcher
@@ -20,6 +24,9 @@ export declare class RouteGroup extends Macroable {
20
24
  * Route.group(() => {
21
25
  * }).where('id', /^[0-9]+/)
22
26
  * ```
27
+ * @param param - The parameter name to match
28
+ * @param matcher - The matcher pattern (RegExp, string, or RouteMatcher)
29
+ * @returns Current RouteGroup instance for method chaining
23
30
  */
24
31
  where(param: string, matcher: RouteMatcher | string | RegExp): this;
25
32
  /**
@@ -29,6 +36,8 @@ export declare class RouteGroup extends Macroable {
29
36
  * Route.group(() => {
30
37
  * }).prefix('v1')
31
38
  * ```
39
+ * @param prefix - The prefix to add to all routes in the group
40
+ * @returns Current RouteGroup instance for method chaining
32
41
  */
33
42
  prefix(prefix: string): this;
34
43
  /**
@@ -38,6 +47,8 @@ export declare class RouteGroup extends Macroable {
38
47
  * Route.group(() => {
39
48
  * }).domain(':name.adonisjs.com')
40
49
  * ```
50
+ * @param domain - The domain pattern for all routes in the group
51
+ * @returns Current RouteGroup instance for method chaining
41
52
  */
42
53
  domain(domain: string): this;
43
54
  /**
@@ -47,6 +58,8 @@ export declare class RouteGroup extends Macroable {
47
58
  * Route.group(() => {
48
59
  * }).as('version1')
49
60
  * ```
61
+ * @param name - The name to prepend to all route names in the group
62
+ * @returns Current RouteGroup instance for method chaining
50
63
  */
51
64
  as(name: string): this;
52
65
  /**
@@ -56,10 +69,14 @@ export declare class RouteGroup extends Macroable {
56
69
  * Route.group(() => {
57
70
  * }).use(middleware.auth())
58
71
  * ```
72
+ * @param middleware - Middleware function(s) to apply to all routes in the group
73
+ * @returns Current RouteGroup instance for method chaining
59
74
  */
60
75
  use(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this;
61
76
  /**
62
- * @alias use
77
+ * Alias for {@link RouteGroup.use}
78
+ * @param middleware - Middleware function(s) to apply to all routes in the group
79
+ * @returns Current RouteGroup instance for method chaining
63
80
  */
64
81
  middleware(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this;
65
82
  }
@@ -1,4 +1,4 @@
1
- import { type Router } from '../main.js';
1
+ import { type Router } from '../main.ts';
2
2
  /**
3
3
  * URL builder class is used to create URIs for pre-registered
4
4
  * routes.
@@ -12,35 +12,35 @@ import { type Router } from '../main.js';
12
12
  * .make('categories.posts.index')
13
13
  * ```
14
14
  *
15
- * @deprecated
16
- * Instead use "@adonisjs/core/services/url_builder" instead
15
+ * @deprecated Instead use "@adonisjs/core/services/url_builder" instead
17
16
  */
18
17
  export declare class UrlBuilder {
19
18
  #private;
19
+ /**
20
+ * Creates a new UrlBuilder instance
21
+ * @param router - The router instance
22
+ * @param domain - Optional domain for URL generation
23
+ */
20
24
  constructor(router: Router, domain?: string);
21
25
  /**
22
26
  * Prefix a custom base URL to the final URI
23
- * @deprecated
24
- * Instead use "@adonisjs/core/services/url_builder" instead
27
+ * @deprecated Instead use "@adonisjs/core/services/url_builder" instead
25
28
  */
26
29
  prefixUrl(url: string): this;
27
30
  /**
28
31
  * Disable route lookup. Calling this method considers
29
32
  * the "identifier" as the route pattern
30
- * @deprecated
31
- * Instead use "@adonisjs/core/services/url_builder" instead
33
+ * @deprecated Instead use "@adonisjs/core/services/url_builder" instead
32
34
  */
33
35
  disableRouteLookup(): this;
34
36
  /**
35
37
  * Append query string to the final URI
36
- * @deprecated
37
- * Instead use "@adonisjs/core/services/url_builder" instead
38
+ * @deprecated Instead use "@adonisjs/core/services/url_builder" instead
38
39
  */
39
40
  qs(queryString?: Record<string, any>): this;
40
41
  /**
41
42
  * Specify params to apply to the route pattern
42
- * @deprecated
43
- * Instead use "@adonisjs/core/services/url_builder" instead
43
+ * @deprecated Instead use "@adonisjs/core/services/url_builder" instead
44
44
  */
45
45
  params(params?: any[] | Record<string, any>): this;
46
46
  /**
@@ -48,8 +48,9 @@ export declare class UrlBuilder {
48
48
  * route name, controller.method name or the route pattern
49
49
  * itself.
50
50
  *
51
- * @deprecated
52
- * Instead use "@adonisjs/core/services/url_builder" instead
51
+ * @deprecated Instead use "@adonisjs/core/services/url_builder" instead
52
+ * @param identifier - Route identifier to generate URL for
53
+ * @returns Generated URL string
53
54
  */
54
55
  make(identifier: string): string;
55
56
  /**
@@ -57,8 +58,7 @@ export declare class UrlBuilder {
57
58
  * route name, controller.method name or the route pattern
58
59
  * itself.
59
60
  *
60
- * @deprecated
61
- * Instead use "@adonisjs/core/services/url_builder" instead
61
+ * @deprecated Instead use "@adonisjs/core/services/url_builder" instead
62
62
  *
63
63
  */
64
64
  makeSigned(identifier: string, options?: {
@@ -1,17 +1,16 @@
1
1
  import type { Encryption } from '@adonisjs/encryption';
2
2
  import type { Application } from '@adonisjs/application';
3
3
  import type { Constructor, LazyImport } from '@poppinss/utils/types';
4
- import type { Qs } from '../qs.js';
5
- import { Route } from './route.js';
6
- import { RouteGroup } from './group.js';
7
- import { BriskRoute } from './brisk.js';
8
- import { RouteResource } from './resource.js';
9
- import { RouterClient } from '../client/router.ts';
10
- import { UrlBuilder } from './legacy/url_builder.js';
11
- import { RouteMatchers as Matchers } from './matchers.js';
12
- import type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.js';
13
- import type { RouteFn, RouteJSON, RoutesList, MatchedRoute, RouteMatchers, MakeUrlOptions, MakeSignedUrlOptions, GetControllerHandlers } from '../types/route.js';
14
- import { type UrlFor, type LookupList, type SignedURLOptions, type RouteMatcher, type MatchItRouteToken } from '../client/types.ts';
4
+ import type { Qs } from '../qs.ts';
5
+ import { Route } from './route.ts';
6
+ import { RouteGroup } from './group.ts';
7
+ import { BriskRoute } from './brisk.ts';
8
+ import { RouteResource } from './resource.ts';
9
+ import { UrlBuilder } from './legacy/url_builder.ts';
10
+ import { RouteMatchers as Matchers } from './matchers.ts';
11
+ import type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.ts';
12
+ import type { RouteFn, RouteJSON, MatchedRoute, RouteMatcher, RouteMatchers, MakeUrlOptions, MakeSignedUrlOptions, GetControllerHandlers } from '../types/route.ts';
13
+ import { type UrlFor, type LookupList, type RoutesList, type SignedURLOptions } from '../types/url_builder.ts';
15
14
  /**
16
15
  * Router class exposes a unified API to register new routes, group them or
17
16
  * create route resources.
@@ -24,7 +23,7 @@ import { type UrlFor, type LookupList, type SignedURLOptions, type RouteMatcher,
24
23
  * })
25
24
  * ```
26
25
  */
27
- export declare class Router extends RouterClient<RouteJSON> {
26
+ export declare class Router {
28
27
  #private;
29
28
  /**
30
29
  * A flag to know if routes for explicit domains have been registered.
@@ -56,23 +55,45 @@ export declare class Router extends RouterClient<RouteJSON> {
56
55
  urlFor: UrlFor<RoutesList extends LookupList ? RoutesList : never>;
57
56
  signedUrlFor: UrlFor<RoutesList extends LookupList ? RoutesList : never, SignedURLOptions>;
58
57
  };
58
+ /**
59
+ * List of route references kept for lookup.
60
+ */
61
+ protected routes: {
62
+ [domain: string]: RouteJSON[];
63
+ };
64
+ /**
65
+ * Creates a new Router instance
66
+ * @param app - The AdonisJS application instance
67
+ * @param encryption - Encryption service for signed URLs
68
+ * @param qsParser - Query string parser for URL generation
69
+ */
59
70
  constructor(app: Application<any>, encryption: Encryption, qsParser: Qs);
71
+ /**
72
+ * Register route JSON payload
73
+ */
74
+ protected register(route: RouteJSON): void;
60
75
  /**
61
76
  * Parses the route pattern
77
+ * @param pattern - The route pattern to parse
78
+ * @param matchers - Optional route matchers
62
79
  */
63
- parsePattern(pattern: string, matchers?: RouteMatchers): MatchItRouteToken[];
80
+ parsePattern(pattern: string, matchers?: RouteMatchers): import("../types/route.ts").MatchItRouteToken[];
64
81
  /**
65
82
  * Define an array of middleware to use on all the routes.
66
83
  * Calling this method multiple times pushes to the
67
84
  * existing list of middleware
85
+ * @param middleware - Array of middleware classes to apply globally
86
+ * @returns Current Router instance for method chaining
68
87
  */
69
88
  use(middleware: LazyImport<MiddlewareAsClass>[]): this;
70
89
  /**
71
90
  * Define a collection of named middleware. The defined collection is
72
91
  * not registered anywhere, but instead converted in a new collection
73
92
  * of functions you can apply on the routes, or router groups.
93
+ * @param collection - Object mapping middleware names to middleware classes
94
+ * @returns Named middleware functions
74
95
  */
75
- named<NamedMiddleware extends Record<string, LazyImport<MiddlewareAsClass>>>(collection: NamedMiddleware): { [K in keyof NamedMiddleware]: <Args extends import("../types/middleware.js").GetMiddlewareArgs<import("@poppinss/utils/types").UnWrapLazyImport<NamedMiddleware[K]>>>(...args: Args) => {
96
+ named<NamedMiddleware extends Record<string, LazyImport<MiddlewareAsClass>>>(collection: NamedMiddleware): { [K in keyof NamedMiddleware]: <Args extends import("../types/middleware.ts").GetMiddlewareArgs<import("@poppinss/utils/types").UnWrapLazyImport<NamedMiddleware[K]>>>(...args: Args) => {
76
97
  name: K;
77
98
  reference: LazyImport<MiddlewareAsClass> | MiddlewareAsClass;
78
99
  args: Args[0];
@@ -80,52 +101,87 @@ export declare class Router extends RouterClient<RouteJSON> {
80
101
  }; };
81
102
  /**
82
103
  * Add route for a given pattern and methods
104
+ * @param pattern - The route pattern
105
+ * @param methods - Array of HTTP methods
106
+ * @param handler - Route handler (function, string, or controller tuple)
107
+ * @returns The created route instance
83
108
  */
84
109
  route<T extends Constructor<any>>(pattern: string, methods: string[], handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
85
110
  /**
86
111
  * Define a route that handles all common HTTP methods
112
+ * @param pattern - The route pattern
113
+ * @param handler - Route handler (function, string, or controller tuple)
114
+ * @returns The created route instance
87
115
  */
88
116
  any<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
89
117
  /**
90
118
  * Define `GET` route
119
+ * @param pattern - The route pattern
120
+ * @param handler - Route handler (function, string, or controller tuple)
121
+ * @returns The created route instance
91
122
  */
92
123
  get<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
93
124
  /**
94
125
  * Define `POST` route
126
+ * @param pattern - The route pattern
127
+ * @param handler - Route handler (function, string, or controller tuple)
128
+ * @returns The created route instance
95
129
  */
96
130
  post<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
97
131
  /**
98
132
  * Define `PUT` route
133
+ * @param pattern - The route pattern
134
+ * @param handler - Route handler (function, string, or controller tuple)
135
+ * @returns The created route instance
99
136
  */
100
137
  put<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
101
138
  /**
102
139
  * Define `PATCH` route
140
+ * @param pattern - The route pattern
141
+ * @param handler - Route handler (function, string, or controller tuple)
142
+ * @returns The created route instance
103
143
  */
104
144
  patch<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
105
145
  /**
106
146
  * Define `DELETE` route
147
+ * @param pattern - The route pattern
148
+ * @param handler - Route handler (function, string, or controller tuple)
149
+ * @returns The created route instance
107
150
  */
108
151
  delete<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
109
152
  /**
110
153
  * Creates a group of routes. A route group can apply transforms
111
154
  * to routes in bulk
155
+ * @param callback - Function that defines routes within the group
156
+ * @returns The created route group instance
112
157
  */
113
158
  group(callback: () => void): RouteGroup;
114
159
  /**
115
160
  * Registers a route resource with conventional set of routes
161
+ * @param resource - The resource name
162
+ * @param controller - Controller to handle the resource
163
+ * @returns The created route resource instance
116
164
  */
117
- resource(resource: string, controller: string | LazyImport<Constructor<any>> | Constructor<any>): RouteResource<import("../types/route.js").ResourceActionNames>;
165
+ resource(resource: string, controller: string | LazyImport<Constructor<any>> | Constructor<any>): RouteResource<import("../types/route.ts").ResourceActionNames>;
118
166
  /**
119
167
  * Register a route resource with shallow nested routes.
168
+ * @param resource - The resource name
169
+ * @param controller - Controller to handle the resource
170
+ * @returns The created route resource instance
120
171
  */
121
- shallowResource(resource: string, controller: string | LazyImport<Constructor<any>> | Constructor<any>): RouteResource<import("../types/route.js").ResourceActionNames>;
172
+ shallowResource(resource: string, controller: string | LazyImport<Constructor<any>> | Constructor<any>): RouteResource<import("../types/route.ts").ResourceActionNames>;
122
173
  /**
123
174
  * Returns a brisk route instance for a given URL pattern
175
+ * @param pattern - The route pattern
176
+ * @returns The created brisk route instance
124
177
  */
125
178
  on(pattern: string): BriskRoute;
126
179
  /**
127
180
  * Define matcher for a given param. The global params are applied
128
181
  * on all the routes (unless overridden at the route level).
182
+ * @param param - The parameter name to match
183
+ * @param matcher - The matcher pattern (RegExp, string, or RouteMatcher)
184
+ * @returns Current Router instance for method chaining
129
185
  */
130
186
  where(param: string, matcher: RouteMatcher | string | RegExp): this;
131
187
  /**
@@ -133,22 +189,79 @@ export declare class Router extends RouterClient<RouteJSON> {
133
189
  * commit method is called.
134
190
  */
135
191
  commit(): void;
192
+ /**
193
+ * Finds a route by its identifier. The identifier can be the
194
+ * route name, controller.method name or the route pattern
195
+ * itself.
196
+ *
197
+ * When "disableLegacyLookup" is set, the lookup will be performed
198
+ * only using the route name
199
+ * @param routeIdentifier - Route name, pattern, or controller reference
200
+ * @param domain - Optional domain to search within
201
+ * @param method - Optional HTTP method to filter by
202
+ * @param disableLegacyLookup - Whether to disable legacy lookup strategies
203
+ * @returns Found route or null if not found
204
+ */
205
+ find(routeIdentifier: string, domain?: string, method?: string, disableLegacyLookup?: boolean): RouteJSON | null;
206
+ /**
207
+ * Finds a route by its identifier. The identifier can be the
208
+ * route name, controller.method name or the route pattern
209
+ * itself.
210
+ *
211
+ * An error is raised when unable to find the route.
212
+ *
213
+ * When "disableLegacyLookup" is set, the lookup will be performed
214
+ * only using the route name
215
+ * @param routeIdentifier - Route name, pattern, or controller reference
216
+ * @param domain - Optional domain to search within
217
+ * @param method - Optional HTTP method to filter by
218
+ * @param disableLegacyLookup - Whether to disable legacy lookup strategies
219
+ * @returns Found route
220
+ * @throws Error when route is not found
221
+ */
222
+ findOrFail(routeIdentifier: string, domain?: string, method?: string, disableLegacyLookup?: boolean): RouteJSON;
223
+ /**
224
+ * Check if a route exists. The identifier can be the
225
+ * route name, controller.method name or the route pattern
226
+ * itself.
227
+ *
228
+ * When "followLookupStrategy" is enabled, the lookup will be performed
229
+ * on the basis of the lookup strategy enabled via the "lookupStrategies"
230
+ * method. The default lookupStrategy is "name" and "pattern".
231
+ * @param routeIdentifier - Route name, pattern, or controller reference
232
+ * @param domain - Optional domain to search within
233
+ * @param method - Optional HTTP method to filter by
234
+ * @param followLookupStrategy - Whether to follow the configured lookup strategy
235
+ * @returns True if route exists, false otherwise
236
+ */
237
+ has(routeIdentifier: string, domain?: string, method?: string, followLookupStrategy?: boolean): boolean;
238
+ /**
239
+ * Returns a list of routes grouped by their domain names
240
+ * @returns Object mapping domain names to route arrays
241
+ */
242
+ toJSON(): {
243
+ [domain: string]: RouteJSON[];
244
+ };
136
245
  /**
137
246
  * Generates types for the URL builder. These types must
138
247
  * be written inside a file for the URL builder to
139
248
  * pick them up.
249
+ * @param indentation - Indentation level for generated types
250
+ * @returns Generated TypeScript types as string
140
251
  */
141
252
  generateTypes(indentation?: number): string;
142
- generateClient(): string;
143
253
  /**
144
254
  * Find route for a given URL, method and optionally domain
255
+ * @param uri - The URI to match
256
+ * @param method - HTTP method
257
+ * @param shouldDecodeParam - Whether to decode parameters
258
+ * @param hostname - Optional hostname for domain matching
259
+ * @returns Matched route or null if no match found
145
260
  */
146
261
  match(uri: string, method: string, shouldDecodeParam: boolean, hostname?: string | null): null | MatchedRoute;
147
262
  /**
148
263
  * Create URL builder instance.
149
- * @deprecated
150
- *
151
- * Instead use "@adonisjs/core/services/url_builder" instead
264
+ * @deprecated Instead use "@adonisjs/core/services/url_builder" instead
152
265
  */
153
266
  builder(): UrlBuilder;
154
267
  /**
@@ -6,6 +6,7 @@ export declare class RouteMatchers extends Macroable {
6
6
  /**
7
7
  * Enforce value to be a number and also casts it to number data
8
8
  * type
9
+ * @returns Route matcher configuration for numeric values
9
10
  */
10
11
  number(): {
11
12
  match: RegExp;
@@ -13,6 +14,7 @@ export declare class RouteMatchers extends Macroable {
13
14
  };
14
15
  /**
15
16
  * Enforce value to be formatted as uuid
17
+ * @returns Route matcher configuration for UUID values
16
18
  */
17
19
  uuid(): {
18
20
  match: RegExp;
@@ -20,6 +22,7 @@ export declare class RouteMatchers extends Macroable {
20
22
  };
21
23
  /**
22
24
  * Enforce value to be formatted as slug
25
+ * @returns Route matcher configuration for slug values
23
26
  */
24
27
  slug(): {
25
28
  match: RegExp;
@@ -1,10 +1,9 @@
1
1
  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
- import { Route } from './route.js';
5
- import { type RouteMatcher } from '../client/types.ts';
6
- import type { ResourceActionNames, RouteMatchers } from '../types/route.js';
7
- import type { MiddlewareFn, ParsedNamedMiddleware, ParsedGlobalMiddleware } from '../types/middleware.js';
4
+ import { Route } from './route.ts';
5
+ import type { ResourceActionNames, RouteMatcher, RouteMatchers } from '../types/route.ts';
6
+ import type { MiddlewareFn, ParsedNamedMiddleware, ParsedGlobalMiddleware } from '../types/middleware.ts';
8
7
  /**
9
8
  * Route resource exposes the API to register multiple routes for a resource.
10
9
  */
@@ -14,6 +13,12 @@ export declare class RouteResource<ActionNames extends ResourceActionNames = Res
14
13
  * A collection of routes instances that belongs to this resource
15
14
  */
16
15
  routes: Route[];
16
+ /**
17
+ * Creates a new RouteResource instance
18
+ * @param app - The AdonisJS application instance
19
+ * @param routerMiddleware - Array of global middleware registered on the router
20
+ * @param options - Configuration options for the route resource
21
+ */
17
22
  constructor(app: Application<any>, routerMiddleware: ParsedGlobalMiddleware[], options: {
18
23
  resource: string;
19
24
  controller: string | LazyImport<Constructor<any>> | Constructor<any>;
@@ -22,28 +27,46 @@ export declare class RouteResource<ActionNames extends ResourceActionNames = Res
22
27
  });
23
28
  /**
24
29
  * Register only given routes and remove others
30
+ * @param names - Array of action names to keep
31
+ * @returns Current RouteResource instance with filtered actions
25
32
  */
26
33
  only<Name extends ActionNames>(names: Name[]): RouteResource<Name>;
27
34
  /**
28
35
  * Register all routes, except the one's defined
36
+ * @param names - Array of action names to exclude
37
+ * @returns Current RouteResource instance with filtered actions
29
38
  */
30
39
  except<Name extends ActionNames>(names: Name[]): RouteResource<Exclude<ActionNames, Name>>;
31
40
  /**
32
41
  * Register api only routes. The `create` and `edit` routes, which
33
42
  * are meant to show forms will not be registered
43
+ * @returns Current RouteResource instance without create and edit actions
34
44
  */
35
45
  apiOnly(): RouteResource<Exclude<ActionNames, 'create' | 'edit'>>;
36
46
  /**
37
47
  * Define matcher for params inside the resource
48
+ * @param key - The parameter name to match
49
+ * @param matcher - The matcher pattern (RegExp, string, or RouteMatcher)
50
+ * @returns Current RouteResource instance for method chaining
38
51
  */
39
52
  where(key: string, matcher: RouteMatcher | string | RegExp): this;
40
53
  /**
41
54
  * Tap into multiple routes to configure them by their name
55
+ * @param callback - Function to configure routes
56
+ * @returns Current RouteResource instance for method chaining
42
57
  */
43
58
  tap(callback: (route: Route) => void): this;
59
+ /**
60
+ * Tap into multiple routes to configure them by their name
61
+ * @param actions - Action name(s) to configure
62
+ * @param callback - Function to configure matching routes
63
+ * @returns Current RouteResource instance for method chaining
64
+ */
44
65
  tap(actions: ActionNames | ActionNames[], callback: (route: Route) => void): this;
45
66
  /**
46
67
  * Set the param name for a given resource
68
+ * @param resources - Object mapping resource names to parameter names
69
+ * @returns Current RouteResource instance for method chaining
47
70
  */
48
71
  params(resources: {
49
72
  [resource: string]: string;
@@ -54,14 +77,23 @@ export declare class RouteResource<ActionNames extends ResourceActionNames = Res
54
77
  *
55
78
  * Calling this method multiple times will append middleware
56
79
  * to existing list.
80
+ * @param actions - Action name(s) or '*' for all actions
81
+ * @param middleware - Middleware function(s) to apply
82
+ * @returns Current RouteResource instance for method chaining
57
83
  */
58
84
  use(actions: ActionNames | ActionNames[] | '*', middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this;
59
85
  /**
60
- * @alias use
86
+ * Alias for {@link RouteResource.use}
87
+ * @param actions - Action name(s) or '*' for all actions
88
+ * @param middleware - Middleware function(s) to apply
89
+ * @returns Current RouteResource instance for method chaining
61
90
  */
62
91
  middleware(actions: ActionNames | ActionNames[] | '*', middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this;
63
92
  /**
64
93
  * Prepend name to all the routes
94
+ * @param name - The name to prepend to all route names
95
+ * @param normalizeName - Whether to normalize the name to snake_case
96
+ * @returns Current RouteResource instance for method chaining
65
97
  */
66
98
  as(name: string, normalizeName?: boolean): this;
67
99
  }