@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
@@ -5,63 +5,78 @@ import type { RequestConfig } from './request.ts';
5
5
  import type { ResponseConfig } from './response.ts';
6
6
  import type { HttpContext } from '../http_context/main.ts';
7
7
  /**
8
- * Normalized HTTP error used by the exception
9
- * handler.
8
+ * Normalized HTTP error structure used by exception handlers
10
9
  */
11
10
  export type HttpError = {
11
+ /** Error message describing the issue */
12
12
  message: string;
13
+ /** HTTP status code */
13
14
  status: number;
15
+ /** Optional error code identifier */
14
16
  code?: string;
17
+ /** Optional stack trace */
15
18
  stack?: string;
19
+ /** Optional underlying cause of the error */
16
20
  cause?: any;
21
+ /** Optional additional error messages */
17
22
  messages?: any;
23
+ /** Optional validation or field errors */
18
24
  errors?: any;
25
+ /** Optional custom error handler method */
19
26
  handle?: (...args: any[]) => any;
27
+ /** Optional error reporting method */
20
28
  report?: (...args: any[]) => any;
21
29
  };
22
30
  /**
23
- * The pipeline for executing middleware during tests
31
+ * Pipeline interface for executing middleware chains during testing
24
32
  */
25
33
  export interface TestingMiddlewarePipeline {
34
+ /** Set the final handler for the pipeline */
26
35
  finalHandler(handler: FinalHandler): this;
36
+ /** Set the error handler for the pipeline */
27
37
  errorHandler(handler: ErrorHandler): this;
38
+ /** Execute the middleware pipeline with the given context */
28
39
  run(ctx: HttpContext): Promise<any>;
29
40
  }
30
41
  /**
31
- * The expression to define a status page range
42
+ * Expression format for defining HTTP status code ranges for error pages
32
43
  */
33
44
  export type StatusPageRange = `${number}..${number}` | `${number}` | number;
34
45
  /**
35
- * The callback function to render status page for a given
36
- * error.
46
+ * Callback function to render custom status pages for HTTP errors
37
47
  */
38
48
  export type StatusPageRenderer = (error: HttpError, ctx: HttpContext) => any | Promise<any>;
39
49
  /**
40
- * Data type for the "http:request_completed" event
50
+ * Payload structure for the http:request_completed event
41
51
  */
42
52
  export type HttpRequestFinishedPayload = {
53
+ /** HTTP context for the completed request */
43
54
  ctx: HttpContext;
55
+ /** Request duration as a high-resolution time tuple */
44
56
  duration: [number, number];
45
57
  };
46
58
  /**
47
- * Events emitted by the HttpServer
59
+ * Event types and payloads emitted by the HTTP server
48
60
  */
49
61
  export type HttpServerEvents = {
62
+ /** Event fired when an HTTP request is completed */
50
63
  'http:request_completed': HttpRequestFinishedPayload;
51
64
  };
52
65
  /**
53
- * Error handler to handle HTTP errors
66
+ * Interface for handling and reporting HTTP errors in the server
54
67
  */
55
68
  export type ServerErrorHandler = {
69
+ /** Method to report errors for logging or monitoring */
56
70
  report: (error: any, ctx: HttpContext) => any;
71
+ /** Method to handle errors and send appropriate responses */
57
72
  handle: (error: any, ctx: HttpContext) => any;
58
73
  };
59
74
  /**
60
- * Error handler represented as a class
75
+ * Constructor type for error handler classes that implement ServerErrorHandler
61
76
  */
62
77
  export type ErrorHandlerAsAClass = Constructor<ServerErrorHandler>;
63
78
  /**
64
- * Config accepted by the HTTP server
79
+ * Complete configuration options for the HTTP server extending request and response configs
65
80
  */
66
81
  export type ServerConfig = RequestConfig & ResponseConfig & {
67
82
  /**
@@ -1,6 +1,24 @@
1
1
  import type { RouteJSON } from './route.ts';
2
2
  import type { HttpContext } from '../http_context/main.ts';
3
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;
4
+ /**
5
+ * Tracing data structure for HTTP request events
6
+ */
7
+ export type HTTPRequestTracingData = {
8
+ /** HTTP context for the traced request */
9
+ ctx: HttpContext;
10
+ };
11
+ /**
12
+ * Tracing data structure for middleware execution events
13
+ */
14
+ export type MiddlewareTracingData = {
15
+ /** The middleware being traced */
16
+ middleware: ParsedGlobalMiddleware | ParsedNamedMiddleware | MiddlewareFn;
17
+ };
18
+ /**
19
+ * Tracing data structure for route handler execution events
20
+ */
21
+ export type RouteHandlerTracingData = {
22
+ /** The route being traced */
23
+ route: RouteJSON;
24
+ };
@@ -1,147 +1,22 @@
1
+ import { type UrlFor, type LookupList, type URLOptions, type LookupListRoute, type RouteBuilderArguments } from '../client/types.ts';
2
+ export { URLOptions, LookupListRoute, RouteBuilderArguments, LookupList, UrlFor };
1
3
  /**
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
4
+ * Configuration options for signed URL generation helpers
14
5
  */
15
6
  export type SignedURLOptions = URLOptions & {
7
+ /** Expiration time for the signed URL */
16
8
  expiresIn?: string | number;
9
+ /** Purpose identifier for the signed URL */
17
10
  purpose?: string;
18
11
  };
19
12
  /**
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
- * ```
13
+ * Utility type to extract routes for a specific HTTP method from the routes collection
59
14
  */
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
- };
15
+ export type GetRoutesForMethod<Routes, Method> = {
16
+ [K in keyof Routes]: Method extends K ? Routes[Method] : never;
17
+ }[keyof Routes];
135
18
  /**
136
- * To be generated by the router and used by the URL builder
137
- * and the LookupStore
19
+ * Interface to be augmented by the router containing all registered routes for type-safe URL generation
138
20
  */
139
21
  export interface RoutesList {
140
22
  }
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
- };
@@ -4,23 +4,88 @@ import { BriskRoute } from './router/brisk.ts';
4
4
  import type { RouteJSON } from './types/route.ts';
5
5
  import { RouteResource } from './router/resource.ts';
6
6
  /**
7
- * Makes input string consistent by having only the starting
8
- * slash
7
+ * Makes input string consistent by having only the starting slash.
8
+ *
9
+ * Removes trailing slashes and ensures the path starts with a forward slash,
10
+ * except for the root path '/' which remains unchanged.
11
+ *
12
+ * @param input - The input path string to normalize
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * dropSlash('/users/') // '/users'
17
+ * dropSlash('users') // '/users'
18
+ * dropSlash('/') // '/'
19
+ * ```
9
20
  */
10
21
  export declare function dropSlash(input: string): string;
11
22
  /**
12
- * Returns a flat list of routes from the route groups and resources
23
+ * Returns a flat list of routes from route groups, resources, and brisk routes.
24
+ *
25
+ * This function recursively processes route collections, extracting individual routes
26
+ * from groups and resources while filtering out any deleted routes.
27
+ *
28
+ * @param routes - Array containing route groups, individual routes, resources, and brisk routes
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const flatRoutes = toRoutesJSON([
33
+ * routeGroup,
34
+ * singleRoute,
35
+ * resourceRoutes
36
+ * ])
37
+ * ```
13
38
  */
14
39
  export declare function toRoutesJSON(routes: (RouteGroup | Route | RouteResource | BriskRoute)[]): RouteJSON[];
15
40
  /**
16
- * Helper to know if the remote address should
17
- * be trusted.
41
+ * Helper to determine if a remote address should be trusted.
42
+ *
43
+ * Uses caching to avoid repeated expensive proxy function calls for the same
44
+ * remote address. The cache improves performance when the same addresses are
45
+ * checked multiple times.
46
+ *
47
+ * @param remoteAddress - The remote IP address to check
48
+ * @param proxyFn - Function that determines if an address should be trusted
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const isTrusted = trustProxy('192.168.1.1', proxyAddr.compile('loopback'))
53
+ * ```
18
54
  */
19
55
  export declare function trustProxy(remoteAddress: string, proxyFn: (addr: string, distance: number) => boolean): boolean;
20
56
  /**
21
- * Parses a range expression to an object filled with the range
57
+ * Parses a range expression (e.g., '200..299') into an object with numeric keys.
58
+ *
59
+ * Supports both single values and ranges. For ranges, all numbers between
60
+ * the start and end (inclusive) are mapped to the provided value.
61
+ *
62
+ * @param range - Range expression as a string (e.g., '200', '200..299')
63
+ * @param value - Value to assign to each number in the range
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * parseRange('200', 'success') // { 200: 'success' }
68
+ * parseRange('200..202', 'success') // { 200: 'success', 201: 'success', 202: 'success' }
69
+ * ```
22
70
  */
23
71
  export declare function parseRange<T>(range: string, value: T): Record<number, T>;
72
+ /**
73
+ * Safely decodes a URI path while handling special characters and query strings.
74
+ *
75
+ * This function carefully parses and decodes URI components, handling edge cases
76
+ * like double-encoded characters and non-standard query string delimiters.
77
+ * It separates the pathname from query parameters and determines whether
78
+ * route parameters should be decoded.
79
+ *
80
+ * @param path - The URI path to decode
81
+ * @param useSemicolonDelimiter - Whether to treat semicolons as query string delimiters
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * const result = safeDecodeURI('/users/123?name=john', false)
86
+ * // Returns: { pathname: '/users/123', query: 'name=john', shouldDecodeParam: false }
87
+ * ```
88
+ */
24
89
  export declare function safeDecodeURI(path: string, useSemicolonDelimiter: boolean): {
25
90
  pathname: string;
26
91
  query: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonisjs/http-server",
3
- "version": "8.0.0-next.1",
3
+ "version": "8.0.0-next.10",
4
4
  "description": "AdonisJS HTTP server with support packed with Routing and Cookies",
5
5
  "main": "build/index.js",
6
6
  "type": "module",
@@ -13,6 +13,7 @@
13
13
  ".": "./build/index.js",
14
14
  "./helpers": "./build/src/helpers.js",
15
15
  "./types": "./build/src/types/main.js",
16
+ "./client/url_builder": "./build/src/client/url_builder.js",
16
17
  "./factories": "./build/factories/main.js"
17
18
  },
18
19
  "engines": {
@@ -32,7 +33,8 @@
32
33
  "format": "prettier --write .",
33
34
  "prepublishOnly": "npm run build",
34
35
  "lint": "eslint",
35
- "quick:test": "node --import=@poppinss/ts-exec --enable-source-maps bin/test.ts"
36
+ "quick:test": "node --import=@poppinss/ts-exec --enable-source-maps bin/test.ts",
37
+ "docs": "typedoc"
36
38
  },
37
39
  "keywords": [
38
40
  "http",
@@ -41,12 +43,12 @@
41
43
  "author": "virk,adonisjs",
42
44
  "license": "MIT",
43
45
  "devDependencies": {
44
- "@adonisjs/application": "^9.0.0-next.2",
45
- "@adonisjs/encryption": "^7.0.0-next.0",
46
- "@adonisjs/eslint-config": "^3.0.0-next.0",
47
- "@adonisjs/events": "^10.1.0-next.1",
48
- "@adonisjs/fold": "^11.0.0-next.0",
49
- "@adonisjs/logger": "^7.0.0-next.1",
46
+ "@adonisjs/application": "^9.0.0-next.4",
47
+ "@adonisjs/encryption": "^7.0.0-next.1",
48
+ "@adonisjs/eslint-config": "^3.0.0-next.1",
49
+ "@adonisjs/events": "^10.1.0-next.2",
50
+ "@adonisjs/fold": "^11.0.0-next.2",
51
+ "@adonisjs/logger": "^7.1.0-next.0",
50
52
  "@adonisjs/prettier-config": "^1.4.5",
51
53
  "@adonisjs/tsconfig": "^2.0.0-next.0",
52
54
  "@fastify/middie": "^9.0.3",
@@ -65,7 +67,7 @@
65
67
  "@types/fresh": "^0.5.3",
66
68
  "@types/fs-extra": "^11.0.4",
67
69
  "@types/mime-types": "^3.0.1",
68
- "@types/node": "^24.2.1",
70
+ "@types/node": "^24.7.0",
69
71
  "@types/on-finished": "^2.3.5",
70
72
  "@types/pem": "^1.14.4",
71
73
  "@types/proxy-addr": "^2.0.3",
@@ -76,27 +78,28 @@
76
78
  "@vinejs/vine": "^3.0.1",
77
79
  "autocannon": "^8.0.0",
78
80
  "c8": "^10.1.3",
79
- "cross-env": "^10.0.0",
80
- "eslint": "^9.33.0",
81
- "fastify": "^5.5.0",
82
- "fs-extra": "^11.3.1",
81
+ "cross-env": "^10.1.0",
82
+ "eslint": "^9.37.0",
83
+ "fastify": "^5.6.1",
84
+ "fs-extra": "^11.3.2",
83
85
  "get-port": "^7.1.0",
84
86
  "http-status-codes": "^2.3.0",
85
87
  "pem": "^1.14.8",
86
88
  "prettier": "^3.6.2",
87
89
  "reflect-metadata": "^0.2.2",
88
- "release-it": "^19.0.4",
90
+ "release-it": "^19.0.5",
89
91
  "supertest": "^7.1.4",
90
92
  "tsup": "^8.5.0",
91
- "typescript": "^5.9.2",
93
+ "typedoc": "^0.28.13",
94
+ "typescript": "^5.9.3",
92
95
  "youch": "^4.1.0-beta.11"
93
96
  },
94
97
  "dependencies": {
95
- "@poppinss/macroable": "^1.0.5",
98
+ "@poppinss/macroable": "^1.1.0",
96
99
  "@poppinss/matchit": "^3.2.0",
97
100
  "@poppinss/middleware": "^3.2.6",
98
101
  "@poppinss/utils": "^7.0.0-next.3",
99
- "@sindresorhus/is": "^7.0.2",
102
+ "@sindresorhus/is": "^7.1.0",
100
103
  "accepts": "^1.3.8",
101
104
  "content-disposition": "^0.5.4",
102
105
  "cookie": "^1.0.2",
@@ -113,11 +116,11 @@
113
116
  "vary": "^1.1.2"
114
117
  },
115
118
  "peerDependencies": {
116
- "@adonisjs/application": "^9.0.0-next.2",
117
- "@adonisjs/encryption": "^7.0.0-next.0",
118
- "@adonisjs/events": "^10.1.0-next.1",
119
- "@adonisjs/fold": "^11.0.0-next.0",
120
- "@adonisjs/logger": "^7.0.0-next.1",
119
+ "@adonisjs/application": "^9.0.0-next.4",
120
+ "@adonisjs/encryption": "^7.0.0-next.1",
121
+ "@adonisjs/events": "^10.1.0-next.2",
122
+ "@adonisjs/fold": "^11.0.0-next.2",
123
+ "@adonisjs/logger": "^7.1.0-next.0",
121
124
  "youch": "^4.1.0-beta.11"
122
125
  },
123
126
  "peerDependenciesMeta": {
@@ -179,6 +182,7 @@
179
182
  "./index.ts",
180
183
  "./src/helpers.ts",
181
184
  "./src/types/main.ts",
185
+ "./src/client/url_builder.ts",
182
186
  "./factories/main.ts"
183
187
  ],
184
188
  "outDir": "./build",
@@ -1,76 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
5
- };
6
-
7
- // src/helpers.ts
8
- import cookie from "cookie";
9
- import matchit from "@poppinss/matchit";
10
- import string from "@poppinss/utils/string";
11
- import { parseBindingReference } from "@adonisjs/fold";
12
- import { default as default2 } from "encodeurl";
13
- import { default as default3 } from "mime-types";
14
- function parseRoute(pattern, matchers) {
15
- const tokens = matchit.parse(pattern, matchers);
16
- return tokens;
17
- }
18
- function matchRoute(url, patterns) {
19
- const tokensBucket = patterns.map((pattern) => parseRoute(pattern));
20
- const match = matchit.match(url, tokensBucket);
21
- if (!match.length) {
22
- return null;
23
- }
24
- return matchit.exec(url, match);
25
- }
26
- function serializeCookie(key, value, options) {
27
- let expires;
28
- let maxAge;
29
- if (options) {
30
- expires = typeof options.expires === "function" ? options.expires() : options.expires;
31
- maxAge = options.maxAge ? string.seconds.parse(options.maxAge) : void 0;
32
- }
33
- return cookie.serialize(key, value, { ...options, maxAge, expires });
34
- }
35
- async function middlewareInfo(middleware) {
36
- if (typeof middleware === "function") {
37
- return {
38
- type: "closure",
39
- name: middleware.name || "closure"
40
- };
41
- }
42
- if ("args" in middleware) {
43
- return {
44
- type: "named",
45
- name: middleware.name,
46
- args: middleware.args,
47
- ...await parseBindingReference([middleware.reference])
48
- };
49
- }
50
- return {
51
- type: "global",
52
- name: middleware.name,
53
- ...await parseBindingReference([middleware.reference])
54
- };
55
- }
56
- async function routeInfo(route) {
57
- return "reference" in route.handler ? {
58
- type: "controller",
59
- ...await parseBindingReference(route.handler.reference)
60
- } : {
61
- type: "closure",
62
- name: route.handler.name || "closure",
63
- args: "listArgs" in route.handler ? String(route.handler.listArgs) : void 0
64
- };
65
- }
66
-
67
- export {
68
- __export,
69
- parseRoute,
70
- matchRoute,
71
- serializeCookie,
72
- middlewareInfo,
73
- routeInfo,
74
- default2 as default,
75
- default3 as default2
76
- };
@@ -1,14 +0,0 @@
1
- import { type Router } from './main.ts';
2
- import { type MatchItRouteToken } from '../types/route.ts';
3
- import { type UrlFor, type LookupList, type URLOptions } from '../types/url_builder.ts';
4
- /**
5
- * Makes URL for a given route pattern. The route pattern could be an
6
- * identifier or an array of tokens.
7
- */
8
- export declare function createURL(identifier: string, tokens: Pick<MatchItRouteToken, 'val' | 'type' | 'end'>[], searchParamsStringifier: (qs: Record<string, any>) => string, params?: any[] | {
9
- [param: string]: any;
10
- }, options?: URLOptions): string;
11
- /**
12
- * Creates the URLBuilder helper
13
- */
14
- export declare function createUrlBuilder<Routes extends LookupList>(router: Router, searchParamsStringifier: (qs: Record<string, any>) => string): UrlFor<Routes>;