@adonisjs/http-server 8.0.0-next.1 → 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 (67) 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-HMYAZG76.js → chunk-YBLFT4O6.js} +1146 -1663
  5. package/build/factories/http_context.d.ts +2 -1
  6. package/build/factories/http_server.d.ts +7 -0
  7. package/build/factories/main.js +33 -5
  8. package/build/factories/qs_parser_factory.d.ts +3 -2
  9. package/build/factories/request.d.ts +1 -0
  10. package/build/factories/response.d.ts +1 -0
  11. package/build/factories/router.d.ts +1 -0
  12. package/build/factories/server_factory.d.ts +1 -0
  13. package/build/factories/url_builder_factory.d.ts +3 -2
  14. package/build/index.d.ts +4 -1
  15. package/build/index.js +97 -42
  16. package/build/src/client/helpers.d.ts +37 -0
  17. package/build/src/client/types.d.ts +203 -0
  18. package/build/src/client/url_builder.d.ts +15 -0
  19. package/build/src/client/url_builder.js +12 -0
  20. package/build/src/cookies/client.d.ts +61 -3
  21. package/build/src/cookies/drivers/encrypted.d.ts +13 -0
  22. package/build/src/cookies/drivers/plain.d.ts +9 -0
  23. package/build/src/cookies/drivers/signed.d.ts +13 -0
  24. package/build/src/cookies/parser.d.ts +18 -0
  25. package/build/src/cookies/serializer.d.ts +21 -2
  26. package/build/src/debug.d.ts +13 -0
  27. package/build/src/define_config.d.ts +20 -4
  28. package/build/src/define_middleware.d.ts +20 -4
  29. package/build/src/errors.d.ts +60 -5
  30. package/build/src/exception_handler.d.ts +93 -39
  31. package/build/src/helpers.d.ts +57 -0
  32. package/build/src/helpers.js +9 -1
  33. package/build/src/http_context/local_storage.d.ts +17 -0
  34. package/build/src/http_context/main.d.ts +68 -10
  35. package/build/src/qs.d.ts +30 -2
  36. package/build/src/redirect.d.ts +84 -12
  37. package/build/src/request.d.ts +118 -12
  38. package/build/src/response.d.ts +416 -203
  39. package/build/src/response_status.d.ts +14 -0
  40. package/build/src/router/brisk.d.ts +15 -4
  41. package/build/src/router/executor.d.ts +4 -0
  42. package/build/src/router/factories/use_return_value.d.ts +5 -0
  43. package/build/src/router/group.d.ts +18 -1
  44. package/build/src/router/legacy/url_builder.d.ts +14 -14
  45. package/build/src/router/main.d.ts +79 -22
  46. package/build/src/router/matchers.d.ts +3 -0
  47. package/build/src/router/resource.d.ts +34 -1
  48. package/build/src/router/route.d.ts +28 -3
  49. package/build/src/router/signed_url_builder.d.ts +4 -8
  50. package/build/src/router/store.d.ts +9 -0
  51. package/build/src/server/factories/middleware_handler.d.ts +10 -1
  52. package/build/src/server/factories/route_finder.d.ts +13 -3
  53. package/build/src/server/factories/write_response.d.ts +9 -2
  54. package/build/src/server/main.d.ts +77 -23
  55. package/build/src/tracing_channels.d.ts +4 -4
  56. package/build/src/types/middleware.d.ts +34 -9
  57. package/build/src/types/qs.d.ts +5 -0
  58. package/build/src/types/request.d.ts +1 -1
  59. package/build/src/types/response.d.ts +14 -6
  60. package/build/src/types/route.d.ts +42 -42
  61. package/build/src/types/server.d.ts +26 -11
  62. package/build/src/types/tracing_channels.d.ts +21 -3
  63. package/build/src/types/url_builder.d.ts +10 -135
  64. package/build/src/utils.d.ts +71 -6
  65. package/package.json +26 -22
  66. package/build/chunk-ASX56VAK.js +0 -76
  67. package/build/src/router/url_builder.d.ts +0 -14
@@ -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;
@@ -3,7 +3,7 @@ import type { Application } from '@adonisjs/application';
3
3
  import { Route } from './route.ts';
4
4
  import type { RouteFn, RouteMatchers } from '../types/route.ts';
5
5
  import type { ParsedGlobalMiddleware } from '../types/middleware.ts';
6
- import type { RoutesList, URLOptions, GetRoutesForMethod, RouteBuilderArguments } from '../types/url_builder.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;
@@ -5,5 +5,9 @@ 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>;
@@ -2,10 +2,15 @@ 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;
@@ -12,6 +12,10 @@ import type { MiddlewareFn, ParsedNamedMiddleware } from '../types/middleware.ts
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
  }
@@ -12,35 +12,35 @@ import { type Router } from '../main.ts';
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?: {
@@ -9,7 +9,7 @@ import { RouteResource } from './resource.ts';
9
9
  import { UrlBuilder } from './legacy/url_builder.ts';
10
10
  import { RouteMatchers as Matchers } from './matchers.ts';
11
11
  import type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.ts';
12
- import type { RouteFn, RouteJSON, MatchedRoute, RouteMatchers, MakeUrlOptions, MakeSignedUrlOptions, GetControllerHandlers, RouteMatcher } from '../types/route.ts';
12
+ import type { RouteFn, RouteJSON, MatchedRoute, RouteMatcher, RouteMatchers, MakeUrlOptions, MakeSignedUrlOptions, GetControllerHandlers } from '../types/route.ts';
13
13
  import { type UrlFor, type LookupList, type RoutesList, type SignedURLOptions } from '../types/url_builder.ts';
14
14
  /**
15
15
  * Router class exposes a unified API to register new routes, group them or
@@ -61,6 +61,12 @@ export declare class Router {
61
61
  protected routes: {
62
62
  [domain: string]: RouteJSON[];
63
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
+ */
64
70
  constructor(app: Application<any>, encryption: Encryption, qsParser: Qs);
65
71
  /**
66
72
  * Register route JSON payload
@@ -68,18 +74,24 @@ export declare class Router {
68
74
  protected register(route: RouteJSON): void;
69
75
  /**
70
76
  * Parses the route pattern
77
+ * @param pattern - The route pattern to parse
78
+ * @param matchers - Optional route matchers
71
79
  */
72
80
  parsePattern(pattern: string, matchers?: RouteMatchers): import("../types/route.ts").MatchItRouteToken[];
73
81
  /**
74
82
  * Define an array of middleware to use on all the routes.
75
83
  * Calling this method multiple times pushes to the
76
84
  * existing list of middleware
85
+ * @param middleware - Array of middleware classes to apply globally
86
+ * @returns Current Router instance for method chaining
77
87
  */
78
88
  use(middleware: LazyImport<MiddlewareAsClass>[]): this;
79
89
  /**
80
90
  * Define a collection of named middleware. The defined collection is
81
91
  * not registered anywhere, but instead converted in a new collection
82
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
83
95
  */
84
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) => {
85
97
  name: K;
@@ -89,52 +101,87 @@ export declare class Router {
89
101
  }; };
90
102
  /**
91
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
92
108
  */
93
109
  route<T extends Constructor<any>>(pattern: string, methods: string[], handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
94
110
  /**
95
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
96
115
  */
97
116
  any<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
98
117
  /**
99
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
100
122
  */
101
123
  get<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
102
124
  /**
103
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
104
129
  */
105
130
  post<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
106
131
  /**
107
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
108
136
  */
109
137
  put<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
110
138
  /**
111
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
112
143
  */
113
144
  patch<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
114
145
  /**
115
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
116
150
  */
117
151
  delete<T extends Constructor<any>>(pattern: string, handler: string | RouteFn | [LazyImport<T> | T, GetControllerHandlers<T>?]): Route<T>;
118
152
  /**
119
153
  * Creates a group of routes. A route group can apply transforms
120
154
  * to routes in bulk
155
+ * @param callback - Function that defines routes within the group
156
+ * @returns The created route group instance
121
157
  */
122
158
  group(callback: () => void): RouteGroup;
123
159
  /**
124
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
125
164
  */
126
165
  resource(resource: string, controller: string | LazyImport<Constructor<any>> | Constructor<any>): RouteResource<import("../types/route.ts").ResourceActionNames>;
127
166
  /**
128
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
129
171
  */
130
172
  shallowResource(resource: string, controller: string | LazyImport<Constructor<any>> | Constructor<any>): RouteResource<import("../types/route.ts").ResourceActionNames>;
131
173
  /**
132
174
  * Returns a brisk route instance for a given URL pattern
175
+ * @param pattern - The route pattern
176
+ * @returns The created brisk route instance
133
177
  */
134
178
  on(pattern: string): BriskRoute;
135
179
  /**
136
180
  * Define matcher for a given param. The global params are applied
137
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
138
185
  */
139
186
  where(param: string, matcher: RouteMatcher | string | RegExp): this;
140
187
  /**
@@ -142,26 +189,20 @@ export declare class Router {
142
189
  * commit method is called.
143
190
  */
144
191
  commit(): void;
145
- /**
146
- * The lookup strategies to follow when generating URL builder
147
- * types and client
148
- */
149
- lookupStrategies: ('name' | 'pattern' | 'controller')[];
150
- /**
151
- * Define the lookup strategies to follow when generating URL builder
152
- * types and client.
153
- */
154
- updateLookupStrategies(strategies: ('name' | 'pattern' | 'controller')[]): this;
155
192
  /**
156
193
  * Finds a route by its identifier. The identifier can be the
157
194
  * route name, controller.method name or the route pattern
158
195
  * itself.
159
196
  *
160
- * When "followLookupStrategy" is enabled, the lookup will be performed
161
- * on the basis of the lookup strategy enabled via the "lookupStrategies"
162
- * method. The default lookupStrategy is "name" and "pattern".
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
163
204
  */
164
- find(routeIdentifier: string, domain?: string, method?: string, followLookupStrategy?: boolean): RouteJSON | null;
205
+ find(routeIdentifier: string, domain?: string, method?: string, disableLegacyLookup?: boolean): RouteJSON | null;
165
206
  /**
166
207
  * Finds a route by its identifier. The identifier can be the
167
208
  * route name, controller.method name or the route pattern
@@ -169,11 +210,16 @@ export declare class Router {
169
210
  *
170
211
  * An error is raised when unable to find the route.
171
212
  *
172
- * When "followLookupStrategy" is enabled, the lookup will be performed
173
- * on the basis of the lookup strategy enabled via the "lookupStrategies"
174
- * method. The default lookupStrategy is "name" and "pattern".
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
175
221
  */
176
- findOrFail(routeIdentifier: string, domain?: string, method?: string, followLookupStrategy?: boolean): RouteJSON;
222
+ findOrFail(routeIdentifier: string, domain?: string, method?: string, disableLegacyLookup?: boolean): RouteJSON;
177
223
  /**
178
224
  * Check if a route exists. The identifier can be the
179
225
  * route name, controller.method name or the route pattern
@@ -182,10 +228,16 @@ export declare class Router {
182
228
  * When "followLookupStrategy" is enabled, the lookup will be performed
183
229
  * on the basis of the lookup strategy enabled via the "lookupStrategies"
184
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
185
236
  */
186
237
  has(routeIdentifier: string, domain?: string, method?: string, followLookupStrategy?: boolean): boolean;
187
238
  /**
188
239
  * Returns a list of routes grouped by their domain names
240
+ * @returns Object mapping domain names to route arrays
189
241
  */
190
242
  toJSON(): {
191
243
  [domain: string]: RouteJSON[];
@@ -194,17 +246,22 @@ export declare class Router {
194
246
  * Generates types for the URL builder. These types must
195
247
  * be written inside a file for the URL builder to
196
248
  * pick them up.
249
+ * @param indentation - Indentation level for generated types
250
+ * @returns Generated TypeScript types as string
197
251
  */
198
252
  generateTypes(indentation?: number): string;
199
253
  /**
200
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
201
260
  */
202
261
  match(uri: string, method: string, shouldDecodeParam: boolean, hostname?: string | null): null | MatchedRoute;
203
262
  /**
204
263
  * Create URL builder instance.
205
- * @deprecated
206
- *
207
- * Instead use "@adonisjs/core/services/url_builder" instead
264
+ * @deprecated Instead use "@adonisjs/core/services/url_builder" instead
208
265
  */
209
266
  builder(): UrlBuilder;
210
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;
@@ -13,6 +13,12 @@ export declare class RouteResource<ActionNames extends ResourceActionNames = Res
13
13
  * A collection of routes instances that belongs to this resource
14
14
  */
15
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
+ */
16
22
  constructor(app: Application<any>, routerMiddleware: ParsedGlobalMiddleware[], options: {
17
23
  resource: string;
18
24
  controller: string | LazyImport<Constructor<any>> | Constructor<any>;
@@ -21,28 +27,46 @@ export declare class RouteResource<ActionNames extends ResourceActionNames = Res
21
27
  });
22
28
  /**
23
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
24
32
  */
25
33
  only<Name extends ActionNames>(names: Name[]): RouteResource<Name>;
26
34
  /**
27
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
28
38
  */
29
39
  except<Name extends ActionNames>(names: Name[]): RouteResource<Exclude<ActionNames, Name>>;
30
40
  /**
31
41
  * Register api only routes. The `create` and `edit` routes, which
32
42
  * are meant to show forms will not be registered
43
+ * @returns Current RouteResource instance without create and edit actions
33
44
  */
34
45
  apiOnly(): RouteResource<Exclude<ActionNames, 'create' | 'edit'>>;
35
46
  /**
36
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
37
51
  */
38
52
  where(key: string, matcher: RouteMatcher | string | RegExp): this;
39
53
  /**
40
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
41
57
  */
42
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
+ */
43
65
  tap(actions: ActionNames | ActionNames[], callback: (route: Route) => void): this;
44
66
  /**
45
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
46
70
  */
47
71
  params(resources: {
48
72
  [resource: string]: string;
@@ -53,14 +77,23 @@ export declare class RouteResource<ActionNames extends ResourceActionNames = Res
53
77
  *
54
78
  * Calling this method multiple times will append middleware
55
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
56
83
  */
57
84
  use(actions: ActionNames | ActionNames[] | '*', middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this;
58
85
  /**
59
- * @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
60
90
  */
61
91
  middleware(actions: ActionNames | ActionNames[] | '*', middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this;
62
92
  /**
63
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
64
97
  */
65
98
  as(name: string, normalizeName?: boolean): this;
66
99
  }
@@ -4,11 +4,34 @@ import type { Constructor, LazyImport, OneOrMore } from '@poppinss/utils/types';
4
4
  import type { MiddlewareFn, ParsedNamedMiddleware, ParsedGlobalMiddleware } from '../types/middleware.ts';
5
5
  import type { RouteFn, RouteJSON, RouteMatcher, RouteMatchers, StoreRouteMiddleware, GetControllerHandlers } from '../types/route.ts';
6
6
  /**
7
- * The route class exposes the APIs for constructing a route using the
8
- * fluent API.
7
+ * The Route class provides a fluent API for constructing and configuring HTTP routes.
8
+ *
9
+ * Routes define how HTTP requests are handled by mapping URL patterns and HTTP methods
10
+ * to controller actions or inline handlers. This class supports middleware application,
11
+ * parameter validation, naming, and various other route-specific configurations.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const route = new Route(app, middleware, {
16
+ * pattern: '/users/:id',
17
+ * methods: ['GET'],
18
+ * handler: 'UsersController.show'
19
+ * })
20
+ *
21
+ * route
22
+ * .where('id', /^[0-9]+$/)
23
+ * .middleware(['auth'])
24
+ * .as('users.show')
25
+ * ```
9
26
  */
10
27
  export declare class Route<Controller extends Constructor<any> = any> extends Macroable {
11
28
  #private;
29
+ /**
30
+ * Creates a new Route instance
31
+ * @param app - The AdonisJS application instance
32
+ * @param routerMiddleware - Array of global middleware registered on the router
33
+ * @param options - Configuration options for the route
34
+ */
12
35
  constructor(app: Application<any>, routerMiddleware: ParsedGlobalMiddleware[], options: {
13
36
  pattern: string;
14
37
  methods: string[];
@@ -33,6 +56,8 @@ export declare class Route<Controller extends Constructor<any> = any> extends Ma
33
56
  /**
34
57
  * Define prefix for the route. Calling this method multiple times
35
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
36
61
  */
37
62
  prefix(prefix: string): this;
38
63
  /**
@@ -49,7 +74,7 @@ export declare class Route<Controller extends Constructor<any> = any> extends Ma
49
74
  */
50
75
  use(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this;
51
76
  /**
52
- * @alias use
77
+ * Alias for {@link Route.use}
53
78
  */
54
79
  middleware(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this;
55
80
  /**
@@ -1,15 +1,11 @@
1
1
  import type { Encryption } from '@adonisjs/encryption';
2
2
  import { type Router } from './main.ts';
3
- import { type MatchItRouteToken } from '../types/route.ts';
4
3
  import { type UrlFor, type LookupList, type SignedURLOptions } from '../types/url_builder.ts';
5
- /**
6
- * Makes signed URL for a given route pattern. The route pattern could be an
7
- * identifier or an array of tokens.
8
- */
9
- export declare function createSignedURL(identifier: string, tokens: MatchItRouteToken[], searchParamsStringifier: (qs: Record<string, any>) => string, encryption: Encryption, params?: any[] | {
10
- [param: string]: any;
11
- }, options?: SignedURLOptions): string;
12
4
  /**
13
5
  * Creates the URLBuilder helper for making signed URLs
6
+ * @param router - The router instance
7
+ * @param encryption - Encryption service for signing URLs
8
+ * @param searchParamsStringifier - Function to stringify query string parameters
9
+ * @returns URL builder function for creating signed URLs
14
10
  */
15
11
  export declare function createSignedUrlBuilder<Routes extends LookupList>(router: Router, encryption: Encryption, searchParamsStringifier: (qs: Record<string, any>) => string): UrlFor<Routes, SignedURLOptions>;