@adonisjs/http-server 7.7.0 → 8.0.0-next.1

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 (65) hide show
  1. package/build/chunk-ASX56VAK.js +76 -0
  2. package/build/{chunk-6FSCILWX.js → chunk-HMYAZG76.js} +986 -616
  3. package/build/factories/http_context.d.ts +3 -3
  4. package/build/factories/http_server.d.ts +1 -1
  5. package/build/factories/main.d.ts +6 -6
  6. package/build/factories/main.js +87 -87
  7. package/build/factories/qs_parser_factory.d.ts +2 -2
  8. package/build/factories/request.d.ts +2 -2
  9. package/build/factories/response.d.ts +3 -3
  10. package/build/factories/router.d.ts +1 -1
  11. package/build/factories/server_factory.d.ts +2 -2
  12. package/build/factories/url_builder_factory.d.ts +25 -0
  13. package/build/index.d.ts +16 -15
  14. package/build/index.js +25 -23
  15. package/build/src/cookies/client.d.ts +2 -2
  16. package/build/src/cookies/parser.d.ts +2 -2
  17. package/build/src/cookies/serializer.d.ts +8 -2
  18. package/build/src/define_config.d.ts +1 -1
  19. package/build/src/define_middleware.d.ts +4 -3
  20. package/build/src/{exceptions.d.ts → errors.d.ts} +20 -6
  21. package/build/src/exception_handler.d.ts +4 -4
  22. package/build/src/helpers.d.ts +50 -15
  23. package/build/src/helpers.js +18 -0
  24. package/build/src/http_context/local_storage.d.ts +1 -1
  25. package/build/src/http_context/main.d.ts +5 -5
  26. package/build/src/qs.d.ts +3 -3
  27. package/build/src/redirect.d.ts +5 -5
  28. package/build/src/request.d.ts +12 -11
  29. package/build/src/response.d.ts +6 -6
  30. package/build/src/router/brisk.d.ts +6 -5
  31. package/build/src/router/executor.d.ts +4 -4
  32. package/build/src/router/factories/use_return_value.d.ts +6 -1
  33. package/build/src/router/group.d.ts +6 -6
  34. package/build/src/router/{lookup_store → legacy}/url_builder.d.ts +20 -4
  35. package/build/src/router/main.d.ts +117 -21
  36. package/build/src/router/resource.d.ts +4 -4
  37. package/build/src/router/route.d.ts +3 -3
  38. package/build/src/router/signed_url_builder.d.ts +15 -0
  39. package/build/src/router/store.d.ts +2 -2
  40. package/build/src/router/url_builder.d.ts +14 -0
  41. package/build/src/server/factories/middleware_handler.d.ts +4 -4
  42. package/build/src/server/factories/route_finder.d.ts +10 -0
  43. package/build/src/server/factories/write_response.d.ts +1 -1
  44. package/build/src/server/main.d.ts +12 -8
  45. package/build/src/tracing_channels.d.ts +23 -0
  46. package/build/src/types/main.d.ts +7 -7
  47. package/build/src/types/main.js +0 -1
  48. package/build/src/types/middleware.d.ts +35 -2
  49. package/build/src/types/request.d.ts +4 -0
  50. package/build/src/types/response.d.ts +1 -1
  51. package/build/src/types/route.d.ts +50 -49
  52. package/build/src/types/server.d.ts +5 -5
  53. package/build/src/types/tracing_channels.d.ts +6 -0
  54. package/build/src/types/url_builder.d.ts +147 -0
  55. package/build/src/utils.d.ts +28 -0
  56. package/package.json +45 -38
  57. package/build/chunk-6FSCILWX.js.map +0 -1
  58. package/build/factories/main.js.map +0 -1
  59. package/build/index.js.map +0 -1
  60. package/build/src/router/lookup_store/main.d.ts +0 -48
  61. package/build/src/router/lookup_store/route_finder.d.ts +0 -25
  62. package/build/src/router/parser.d.ts +0 -5
  63. package/build/src/server/factories/final_handler.d.ts +0 -10
  64. package/build/src/types/base.d.ts +0 -19
  65. package/build/src/types/main.js.map +0 -1
@@ -1,8 +1,8 @@
1
- import type { NextFn } from '@poppinss/middleware/types';
2
1
  import type { ContainerResolver } from '@adonisjs/fold';
3
- import type { HttpContext } from '../../http_context/main.js';
4
- import { ParsedGlobalMiddleware } from '../../types/middleware.js';
2
+ import type { NextFn } from '@poppinss/middleware/types';
3
+ import type { HttpContext } from '../../http_context/main.ts';
4
+ import { type ParsedGlobalMiddleware } from '../../types/middleware.ts';
5
5
  /**
6
6
  * The middleware handler invokes the middleware functions.
7
7
  */
8
- export declare function middlewareHandler(resolver: ContainerResolver<any>, ctx: HttpContext): (fn: ParsedGlobalMiddleware, next: NextFn) => any;
8
+ export declare function middlewareHandler(resolver: ContainerResolver<any>, ctx: HttpContext): (fn: ParsedGlobalMiddleware, next: NextFn) => Promise<any>;
@@ -0,0 +1,10 @@
1
+ import type { ContainerResolver } from '@adonisjs/fold';
2
+ import type { Router } from '../../router/main.ts';
3
+ import type { HttpContext } from '../../http_context/main.ts';
4
+ import type { ServerErrorHandler } from '../../types/server.ts';
5
+ /**
6
+ * The route finder is executed after the server middleware stack.
7
+ * It looks for a matching route and executes the route middleware
8
+ * stack.
9
+ */
10
+ export declare function routeFinder(router: Router, resolver: ContainerResolver<any>, ctx: HttpContext, errorResponder: ServerErrorHandler['handle']): () => any;
@@ -1,4 +1,4 @@
1
- import type { HttpContext } from '../../http_context/main.js';
1
+ import type { HttpContext } from '../../http_context/main.ts';
2
2
  /**
3
3
  * Writes the response to the socket. The "finish" method can
4
4
  * raise error when unable to serialize the response.
@@ -1,17 +1,17 @@
1
1
  import type { Logger } from '@adonisjs/logger';
2
+ import type { LazyImport } from '@poppinss/utils/types';
2
3
  import type { Encryption } from '@adonisjs/encryption';
3
4
  import type { Server as HttpsServer } from 'node:https';
4
5
  import type { Application } from '@adonisjs/application';
5
6
  import type { EmitterLike } from '@adonisjs/events/types';
6
- import { ContainerResolver } from '@adonisjs/fold';
7
+ import { type ContainerResolver } from '@adonisjs/fold';
7
8
  import type { ServerResponse, IncomingMessage, Server as HttpServer } from 'node:http';
8
- import type { LazyImport } from '../types/base.js';
9
- import type { MiddlewareAsClass } from '../types/middleware.js';
10
- import type { ServerConfig, HttpServerEvents, ErrorHandlerAsAClass, TestingMiddlewarePipeline } from '../types/server.js';
11
- import { Request } from '../request.js';
12
- import { Response } from '../response.js';
13
- import { Router } from '../router/main.js';
14
- import { HttpContext } from '../http_context/main.js';
9
+ import type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.ts';
10
+ import type { ServerConfig, HttpServerEvents, ErrorHandlerAsAClass, TestingMiddlewarePipeline } from '../types/server.ts';
11
+ import { Request } from '../request.ts';
12
+ import { Response } from '../response.ts';
13
+ import { Router } from '../router/main.ts';
14
+ import { HttpContext } from '../http_context/main.ts';
15
15
  /**
16
16
  * The HTTP server implementation to handle incoming requests and respond using the
17
17
  * registered routes.
@@ -75,6 +75,10 @@ export declare class Server {
75
75
  * Creates an instance of the [[HttpContext]] class
76
76
  */
77
77
  createHttpContext(request: Request, response: Response, resolver: ContainerResolver<any>): HttpContext;
78
+ /**
79
+ * Returns a list of server middleware stack
80
+ */
81
+ getMiddlewareList(): ParsedGlobalMiddleware[];
78
82
  /**
79
83
  * Handle request
80
84
  */
@@ -0,0 +1,23 @@
1
+ import diagnostics_channel from 'node:diagnostics_channel';
2
+ import type { MiddlewareTracingData } from './types/tracing_channels.ts';
3
+ /**
4
+ * Traces every HTTP request handled by the {@link Server} class.
5
+ */
6
+ export declare const httpRequest: diagnostics_channel.TracingChannel<"adonisjs:http.request", import("./http_context/main.ts").HttpContext>;
7
+ /**
8
+ * Traces middleware executed during the HTTP request
9
+ */
10
+ export declare const httpMiddleware: diagnostics_channel.TracingChannel<"adonisjs:http.middleware", MiddlewareTracingData>;
11
+ /**
12
+ * Traces the exception handler that converts errors into HTTP responses
13
+ */
14
+ export declare const httpExceptionHandler: diagnostics_channel.TracingChannel<"adonisjs:http.exception.handler", object>;
15
+ /**
16
+ * Traces route handler executed during the HTTP request
17
+ */
18
+ export declare const httpRouteHandler: diagnostics_channel.TracingChannel<"adonisjs:http.route.handler", import("./types/route.ts").RouteJSON>;
19
+ /**
20
+ * Traces non-stream and non-file download responses written by the AdonisJS
21
+ * response class
22
+ */
23
+ export declare const httpResponseSerializer: diagnostics_channel.TracingChannel<"adonisjs:http.response.serializer", object>;
@@ -1,7 +1,7 @@
1
- export * from './base.js';
2
- export * from './middleware.js';
3
- export * from './qs.js';
4
- export * from './request.js';
5
- export * from './response.js';
6
- export * from './route.js';
7
- export * from './server.js';
1
+ export * from './qs.ts';
2
+ export * from './route.ts';
3
+ export * from './server.ts';
4
+ export * from './request.ts';
5
+ export * from './response.ts';
6
+ export * from './url_builder.ts';
7
+ export * from './middleware.ts';
@@ -1 +0,0 @@
1
- //# sourceMappingURL=main.js.map
@@ -1,6 +1,7 @@
1
1
  import type { ContainerResolver } from '@adonisjs/fold';
2
- import type { Constructor, NextFn } from './base.js';
3
- import type { HttpContext } from '../http_context/main.js';
2
+ import type { NextFn } from '@poppinss/middleware/types';
3
+ import type { Constructor, LazyImport } from '@poppinss/utils/types';
4
+ import type { HttpContext } from '../http_context/main.ts';
4
5
  /**
5
6
  * Middleware represented as a class
6
7
  */
@@ -24,6 +25,7 @@ export type MiddlewareFn = (ctx: HttpContext, next: NextFn) => any;
24
25
  */
25
26
  export type ParsedGlobalMiddleware = {
26
27
  name?: string;
28
+ reference: LazyImport<MiddlewareAsClass> | MiddlewareAsClass;
27
29
  handle: (resolver: ContainerResolver<any>, ...args: [ctx: HttpContext, next: NextFn, params?: any]) => any;
28
30
  };
29
31
  /**
@@ -31,7 +33,38 @@ export type ParsedGlobalMiddleware = {
31
33
  */
32
34
  export type ParsedNamedMiddleware = {
33
35
  name: string;
36
+ reference: LazyImport<MiddlewareAsClass> | MiddlewareAsClass;
34
37
  handle: ParsedGlobalMiddleware['handle'];
35
38
  args: any;
36
39
  };
40
+ /**
41
+ * Info node representing a middleware handler
42
+ */
43
+ export type MiddlewareHandlerInfo = {
44
+ type: 'closure';
45
+ name: string;
46
+ } | {
47
+ type: 'named';
48
+ name: string;
49
+ args: any | undefined;
50
+ method: string;
51
+ moduleNameOrPath: string;
52
+ } | {
53
+ type: 'global';
54
+ name?: string | undefined;
55
+ method: string;
56
+ moduleNameOrPath: string;
57
+ };
58
+ /**
59
+ * Info node representing route handler
60
+ */
61
+ export type RouteHandlerInfo = {
62
+ type: 'closure';
63
+ name: string;
64
+ args?: string;
65
+ } | {
66
+ type: 'controller';
67
+ method: string;
68
+ moduleNameOrPath: string;
69
+ };
37
70
  export {};
@@ -17,6 +17,10 @@ export type RequestConfig = {
17
17
  * Defaults to false
18
18
  */
19
19
  generateRequestId: boolean;
20
+ /**
21
+ * A custom method to generate a unique request id. Defaults to uuid v4.
22
+ */
23
+ createRequestId(): string;
20
24
  /**
21
25
  * Method spoofing allows changing the request method using the query string.
22
26
  * For example: Making a POST request on URL /users/1?_method=PATCH will
@@ -1,4 +1,4 @@
1
- import { Readable } from 'node:stream';
1
+ import { type Readable } from 'node:stream';
2
2
  /**
3
3
  * Cookie options can that can be set on the response
4
4
  */
@@ -1,16 +1,16 @@
1
1
  import type Middleware from '@poppinss/middleware';
2
2
  import type { ContainerResolver } from '@adonisjs/fold';
3
- import type { Constructor, LazyImport } from './base.js';
4
- import type { HttpContext } from '../http_context/main.js';
5
- import type { MiddlewareFn, ParsedGlobalMiddleware } from './middleware.js';
6
- import { ServerErrorHandler } from './server.js';
3
+ import type { Constructor, LazyImport } from '@poppinss/utils/types';
4
+ import type { ServerErrorHandler } from './server.ts';
5
+ import type { HttpContext } from '../http_context/main.ts';
6
+ import type { MiddlewareFn, ParsedGlobalMiddleware } from './middleware.ts';
7
7
  /**
8
- * Returns a union of methods from a controller that accepts
9
- * the context as the first argument.
8
+ * Shape of a route param matcher
10
9
  */
11
- export type GetControllerHandlers<Controller extends Constructor<any>> = {
12
- [K in keyof InstanceType<Controller>]: InstanceType<Controller>[K] extends (ctx: HttpContext, ...args: any[]) => any ? K : never;
13
- }[keyof InstanceType<Controller>];
10
+ export type RouteMatcher = {
11
+ match?: RegExp;
12
+ cast?: (value: string) => any;
13
+ };
14
14
  /**
15
15
  * Route token stored by matchit library
16
16
  */
@@ -20,6 +20,13 @@ export type MatchItRouteToken = RouteMatcher & {
20
20
  val: string;
21
21
  end: string;
22
22
  };
23
+ /**
24
+ * Returns a union of methods from a controller that accepts
25
+ * the context as the first argument.
26
+ */
27
+ export type GetControllerHandlers<Controller extends Constructor<any>> = {
28
+ [K in keyof InstanceType<Controller>]: InstanceType<Controller>[K] extends (ctx: HttpContext, ...args: any[]) => any ? K : never;
29
+ }[keyof InstanceType<Controller>];
23
30
  /**
24
31
  * Route handler defined as a function
25
32
  */
@@ -38,36 +45,6 @@ export type StoreRouteMiddleware = MiddlewareFn | ({
38
45
  name?: string;
39
46
  args?: any[];
40
47
  } & ParsedGlobalMiddleware);
41
- /**
42
- * Route node persisted within the routes store
43
- */
44
- export type StoreRouteNode = {
45
- /**
46
- * The execute function to execute the route middleware
47
- * and the handler
48
- */
49
- execute: (route: StoreRouteNode, resolver: ContainerResolver<any>, ctx: HttpContext, errorResponder: ServerErrorHandler['handle']) => any;
50
- /**
51
- * A unique name for the route
52
- */
53
- name?: string;
54
- /**
55
- * Route URI pattern
56
- */
57
- pattern: string;
58
- /**
59
- * Route handler
60
- */
61
- handler: StoreRouteHandler;
62
- /**
63
- * Route middleware
64
- */
65
- middleware: Middleware<StoreRouteMiddleware>;
66
- /**
67
- * Additional metadata associated with the route
68
- */
69
- meta: Record<string, any>;
70
- };
71
48
  /**
72
49
  * An object of routes for a given HTTP method
73
50
  */
@@ -77,7 +54,7 @@ export type StoreMethodNode = {
77
54
  [pattern: string]: string;
78
55
  };
79
56
  routes: {
80
- [pattern: string]: StoreRouteNode;
57
+ [pattern: string]: RouteJSON;
81
58
  };
82
59
  };
83
60
  /**
@@ -100,7 +77,7 @@ export type StoreRoutesTree = {
100
77
  * Shape of the matched route for a pattern, method and domain.
101
78
  */
102
79
  export type MatchedRoute = {
103
- route: StoreRouteNode;
80
+ route: RouteJSON;
104
81
  /**
105
82
  * A unique key for the looked up route
106
83
  */
@@ -114,13 +91,6 @@ export type MatchedRoute = {
114
91
  */
115
92
  subdomains: Record<string, any>;
116
93
  };
117
- /**
118
- * Shape of a route param matcher
119
- */
120
- export type RouteMatcher = {
121
- match?: RegExp;
122
- cast?: (value: string) => any;
123
- };
124
94
  /**
125
95
  * A collection of route matchers
126
96
  */
@@ -130,7 +100,36 @@ export type RouteMatchers = {
130
100
  /**
131
101
  * Representation of a route as JSON
132
102
  */
133
- export type RouteJSON = StoreRouteNode & {
103
+ export type RouteJSON = {
104
+ /**
105
+ * The execute function to execute the route middleware
106
+ * and the handler
107
+ */
108
+ execute: (route: RouteJSON, resolver: ContainerResolver<any>, ctx: HttpContext, errorResponder: ServerErrorHandler['handle']) => any;
109
+ /**
110
+ * A unique name for the route
111
+ */
112
+ name?: string;
113
+ /**
114
+ * Route URI pattern
115
+ */
116
+ pattern: string;
117
+ /**
118
+ * Route handler
119
+ */
120
+ handler: StoreRouteHandler;
121
+ /**
122
+ * Route middleware
123
+ */
124
+ middleware: Middleware<StoreRouteMiddleware>;
125
+ /**
126
+ * Additional metadata associated with the route
127
+ */
128
+ meta: Record<string, any>;
129
+ /**
130
+ * Tokens to be used to construct the route URL
131
+ */
132
+ tokens: MatchItRouteToken[];
134
133
  /**
135
134
  * HTTP methods, the route responds to.
136
135
  */
@@ -150,6 +149,7 @@ export type RouteJSON = StoreRouteNode & {
150
149
  export type ResourceActionNames = 'create' | 'index' | 'store' | 'show' | 'edit' | 'update' | 'destroy';
151
150
  /**
152
151
  * Options accepted by makeUrl method
152
+ * @deprecated
153
153
  */
154
154
  export type MakeUrlOptions = {
155
155
  qs?: Record<string, any>;
@@ -159,6 +159,7 @@ export type MakeUrlOptions = {
159
159
  };
160
160
  /**
161
161
  * Options accepted by makeSignedUrl method
162
+ * @deprecated
162
163
  */
163
164
  export type MakeSignedUrlOptions = MakeUrlOptions & {
164
165
  expiresIn?: string | number;
@@ -1,9 +1,9 @@
1
+ import type { Constructor } from '@poppinss/utils/types';
1
2
  import type { ErrorHandler, FinalHandler } from '@poppinss/middleware/types';
2
- import type { Constructor } from './base.js';
3
- import type { QSParserConfig } from './qs.js';
4
- import type { RequestConfig } from './request.js';
5
- import type { ResponseConfig } from './response.js';
6
- import type { HttpContext } from '../http_context/main.js';
3
+ import type { QSParserConfig } from './qs.ts';
4
+ import type { RequestConfig } from './request.ts';
5
+ import type { ResponseConfig } from './response.ts';
6
+ import type { HttpContext } from '../http_context/main.ts';
7
7
  /**
8
8
  * Normalized HTTP error used by the exception
9
9
  * handler.
@@ -0,0 +1,6 @@
1
+ import type { RouteJSON } from './route.ts';
2
+ import type { HttpContext } from '../http_context/main.ts';
3
+ import type { MiddlewareFn, ParsedGlobalMiddleware, ParsedNamedMiddleware } from './middleware.ts';
4
+ export type HTTPRequestTracingData = HttpContext;
5
+ export type MiddlewareTracingData = ParsedGlobalMiddleware | ParsedNamedMiddleware | MiddlewareFn;
6
+ export type RouteHandlerTracingData = RouteJSON;
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Types shared with the client. These should never import other types
3
+ */
4
+ import { type Prettify } from '@poppinss/utils/types';
5
+ /**
6
+ * Options accepted by "urlFor" helper
7
+ */
8
+ export type URLOptions = {
9
+ qs?: Record<string, any>;
10
+ prefixUrl?: string;
11
+ };
12
+ /**
13
+ * Options accepted by "signedUrlFor" helper
14
+ */
15
+ export type SignedURLOptions = URLOptions & {
16
+ expiresIn?: string | number;
17
+ purpose?: string;
18
+ };
19
+ /**
20
+ * Returns params for a route identifier
21
+ */
22
+ export type RouteBuilderArguments<Routes, Method extends keyof Routes, Identifier extends keyof Routes[Method], Options extends any = URLOptions> = Routes extends LookupList ? Prettify<undefined extends Routes[Method][Identifier]['params'] ? [identifier: Identifier, params?: undefined, options?: Options] : [undefined] extends [Routes[Method][Identifier]['params']] ? [
23
+ identifier: Identifier,
24
+ params?: Routes[Method][Identifier]['params'] | Routes[Method][Identifier]['paramsTuple'],
25
+ options?: Options
26
+ ] : [
27
+ identifier: Identifier,
28
+ params: Routes[Method][Identifier]['params'] | Routes[Method][Identifier]['paramsTuple'],
29
+ options?: Options
30
+ ]> : never;
31
+ /**
32
+ * LookupList type is used by the URLBuilder to provide
33
+ * type-safety when creating URLs.
34
+ *
35
+ * There is no runtime property that matches this type. Its
36
+ * purely for type-inference.
37
+ */
38
+ export type LookupList = {
39
+ [method: string]: {
40
+ [identifier: string]: {
41
+ paramsTuple?: [...any[]];
42
+ params?: {
43
+ [name: string]: any;
44
+ };
45
+ };
46
+ };
47
+ };
48
+ /**
49
+ * The urlFor helper is used to make URLs for pre-existing known routes. You can
50
+ * make a URL using the route name, route pattern, or the route controller
51
+ * reference (depends upon enabled lookupStrategies)
52
+ *
53
+ * ```ts
54
+ * urlFor('users.show', [1]) // /users/1
55
+ *
56
+ * // Lookup inside a specific domain
57
+ * urlFor('blog.adonisjs.com@posts.show', [1]) // /posts/1
58
+ * ```
59
+ */
60
+ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions> = (<Identifier extends keyof Routes['ALL'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'ALL', Identifier, Options>) => string) & {
61
+ /**
62
+ * Make URL for a GET route. An error will be raised if the route doesn't
63
+ * exist.
64
+ *
65
+ * ```ts
66
+ * urlFor.get('users.show', [1]) // { method: 'get', url: '/users/1' }
67
+ * urlFor.get('users.store', [1]) // Error: Route not found GET@users/store
68
+ * ```
69
+ */
70
+ get<RouteIdentifier extends keyof Routes['GET'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'GET', RouteIdentifier, Options>): {
71
+ method: 'get';
72
+ url: string;
73
+ };
74
+ /**
75
+ * Make URL for a POST route. An error will be raised if the route doesn't
76
+ * exist.
77
+ *
78
+ * ```ts
79
+ * urlFor.post('users.store') // { method: 'post', url: '/users' }
80
+ * urlFor.post('users.show', [1]) // Error: Route not found POST@users.show
81
+ * ```
82
+ */
83
+ post<RouteIdentifier extends keyof Routes['POST'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'POST', RouteIdentifier, Options>): {
84
+ method: 'post';
85
+ url: string;
86
+ };
87
+ /**
88
+ * Make URL for a PUT route. An error will be raised if the route doesn't
89
+ * exist.
90
+ *
91
+ * ```ts
92
+ * urlFor.put('users.update', [1]) // { method: 'put', url: '/users/1' }
93
+ * urlFor.put('users.show', [1]) // Error: Route not found PUT@users.show
94
+ * ```
95
+ */
96
+ put<RouteIdentifier extends keyof Routes['PUT'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'PUT', RouteIdentifier, Options>): {
97
+ method: 'put';
98
+ url: string;
99
+ };
100
+ /**
101
+ * Make URL for a PATCH route. An error will be raised if the route doesn't
102
+ * exist.
103
+ *
104
+ * ```ts
105
+ * urlFor.put('users.update', [1]) // { method: 'patch', url: '/users/1' }
106
+ * urlFor.put('users.show', [1]) // Error: Route not found PATCH@users.show
107
+ * ```
108
+ */
109
+ patch<RouteIdentifier extends keyof Routes['PATCH'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'PATCH', RouteIdentifier, Options>): {
110
+ method: 'patch';
111
+ url: string;
112
+ };
113
+ /**
114
+ * Make URL for a DELETE route. An error will be raised if the route doesn't
115
+ * exist.
116
+ *
117
+ * ```ts
118
+ * urlFor.delete('users.destroy', [1]) // { method: 'delete', url: '/users/1' }
119
+ * urlFor.delete('users.show', [1]) // Error: Route not found DELETE@users.show
120
+ * ```
121
+ */
122
+ delete<RouteIdentifier extends keyof Routes['DELETE'] & string>(...[identifier, params, options]: RouteBuilderArguments<Routes, 'DELETE', RouteIdentifier, Options>): {
123
+ method: 'delete';
124
+ url: string;
125
+ };
126
+ /**
127
+ * Make URL for a custom route method. An error will be raised if the route doesn't
128
+ * exist for the same method.
129
+ */
130
+ method<Method extends keyof Routes & string, RouteIdentifier extends keyof Routes[Method] & string>(method: Method, ...[identifier, params, options]: RouteBuilderArguments<Routes, Method, RouteIdentifier, Options>): {
131
+ method: Method;
132
+ url: string;
133
+ };
134
+ };
135
+ /**
136
+ * To be generated by the router and used by the URL builder
137
+ * and the LookupStore
138
+ */
139
+ export interface RoutesList {
140
+ }
141
+ /**
142
+ * Helper to get routes for a given method from the RoutesList. The
143
+ * RoutesList is extended in the userland code.
144
+ */
145
+ export type GetRoutesForMethod<Method> = {
146
+ [K in keyof RoutesList]: Method extends K ? RoutesList[Method] : never;
147
+ };
@@ -0,0 +1,28 @@
1
+ import { type Route } from './router/route.ts';
2
+ import { RouteGroup } from './router/group.ts';
3
+ import { BriskRoute } from './router/brisk.ts';
4
+ import type { RouteJSON } from './types/route.ts';
5
+ import { RouteResource } from './router/resource.ts';
6
+ /**
7
+ * Makes input string consistent by having only the starting
8
+ * slash
9
+ */
10
+ export declare function dropSlash(input: string): string;
11
+ /**
12
+ * Returns a flat list of routes from the route groups and resources
13
+ */
14
+ export declare function toRoutesJSON(routes: (RouteGroup | Route | RouteResource | BriskRoute)[]): RouteJSON[];
15
+ /**
16
+ * Helper to know if the remote address should
17
+ * be trusted.
18
+ */
19
+ export declare function trustProxy(remoteAddress: string, proxyFn: (addr: string, distance: number) => boolean): boolean;
20
+ /**
21
+ * Parses a range expression to an object filled with the range
22
+ */
23
+ export declare function parseRange<T>(range: string, value: T): Record<number, T>;
24
+ export declare function safeDecodeURI(path: string, useSemicolonDelimiter: boolean): {
25
+ pathname: string;
26
+ query: string;
27
+ shouldDecodeParam: boolean;
28
+ };