@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
@@ -0,0 +1,203 @@
1
+ /**
2
+ * Types shared with the client. These should never import other types
3
+ */
4
+ import { type Prettify } from '@poppinss/utils/types';
5
+ export type ClientRouteMatchItTokens = {
6
+ /** Original token string */
7
+ old: string;
8
+ /** Token type identifier (0=static, 1=param, 2=wildcard, 3=optional) */
9
+ type: 0 | 1 | 2 | 3;
10
+ /** Token value */
11
+ val: string;
12
+ /** Token end delimiter */
13
+ end: string;
14
+ };
15
+ /**
16
+ * Complete route definition with all metadata, handlers, and execution context
17
+ */
18
+ export type ClientRouteJSON = {
19
+ /**
20
+ * A unique name for the route
21
+ */
22
+ name?: string;
23
+ /**
24
+ * Route URI pattern
25
+ */
26
+ pattern: string;
27
+ /**
28
+ * Route handler
29
+ */
30
+ handler?: unknown;
31
+ /**
32
+ * Tokens to be used to construct the route URL
33
+ */
34
+ tokens: ClientRouteMatchItTokens[];
35
+ /**
36
+ * HTTP methods, the route responds to.
37
+ */
38
+ methods: string[];
39
+ /**
40
+ * The domain for which the route is registered.
41
+ */
42
+ domain: string;
43
+ };
44
+ /**
45
+ * Configuration options for URL generation helpers
46
+ */
47
+ export type URLOptions = {
48
+ /** Query string parameters to append to the URL */
49
+ qs?: Record<string, any>;
50
+ /** URL prefix to prepend to the generated URL */
51
+ prefixUrl?: string;
52
+ };
53
+ /**
54
+ * LookupList type is used by the URLBuilder to provide
55
+ * type-safety when creating URLs.
56
+ *
57
+ * There is no runtime property that matches this type. Its
58
+ * purely for type-inference.
59
+ */
60
+ /**
61
+ * Route definition structure for type-safe URL building
62
+ */
63
+ export type LookupListRoute = {
64
+ /** Parameters as a tuple for positional arguments */
65
+ paramsTuple?: [...any[]];
66
+ /** Parameters as a named object */
67
+ params?: {
68
+ [name: string]: any;
69
+ };
70
+ };
71
+ /**
72
+ * Complete route lookup structure organized by HTTP methods and route identifiers
73
+ */
74
+ export type LookupList = {
75
+ /** HTTP method to route mapping */
76
+ [method: string]: {
77
+ /** Route identifier to route definition mapping */
78
+ [identifier: string]: LookupListRoute;
79
+ };
80
+ };
81
+ /**
82
+ * Utility type that constructs function arguments for route URL builders based on route parameters
83
+ */
84
+ export type RouteBuilderArguments<Identifier, Route, Options extends any = URLOptions> = Route extends LookupListRoute ? Prettify<Route['params'] extends undefined ? [identifier: Identifier, params?: undefined, options?: Options] : [undefined] extends [Route['params']] ? [
85
+ identifier: Identifier,
86
+ params?: Route['params'] | Route['paramsTuple'],
87
+ options?: Options
88
+ ] : [
89
+ identifier: Identifier,
90
+ params: Route['params'] | Route['paramsTuple'],
91
+ options?: Options
92
+ ]> : never;
93
+ /**
94
+ * The urlFor helper is used to make URLs for pre-existing known routes. You can
95
+ * make a URL using the route name, route pattern, or the route controller
96
+ * reference (depends upon enabled lookupStrategies)
97
+ *
98
+ * ```ts
99
+ * urlFor('users.show', [1]) // /users/1
100
+ *
101
+ * // Lookup inside a specific domain
102
+ * urlFor('blog.adonisjs.com@posts.show', [1]) // /posts/1
103
+ * ```
104
+ */
105
+ export type UrlFor<Routes extends LookupList, Options extends any = URLOptions> = (<Identifier extends keyof Routes['ALL'] & string>(...[identifier, params, options]: RouteBuilderArguments<Identifier, Routes['ALL'][Identifier], Options>) => string) & {
106
+ /**
107
+ * Make URL for a GET route. An error will be raised if the route doesn't
108
+ * exist.
109
+ *
110
+ * ```ts
111
+ * urlFor.get('users.show', [1]) // { method: 'get', url: '/users/1' }
112
+ * urlFor.get('users.store', [1]) // Error: Route not found GET@users/store
113
+ * ```
114
+ */
115
+ get<RouteIdentifier extends keyof Routes['GET'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['GET'][RouteIdentifier], Options>): {
116
+ method: 'GET';
117
+ url: string;
118
+ form: {
119
+ action: string;
120
+ method: 'GET';
121
+ };
122
+ };
123
+ /**
124
+ * Make URL for a POST route. An error will be raised if the route doesn't
125
+ * exist.
126
+ *
127
+ * ```ts
128
+ * urlFor.post('users.store') // { method: 'post', url: '/users' }
129
+ * urlFor.post('users.show', [1]) // Error: Route not found POST@users.show
130
+ * ```
131
+ */
132
+ post<RouteIdentifier extends keyof Routes['POST'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['POST'][RouteIdentifier], Options>): {
133
+ method: 'POST';
134
+ url: string;
135
+ form: {
136
+ action: string;
137
+ method: 'POST';
138
+ };
139
+ };
140
+ /**
141
+ * Make URL for a PUT route. An error will be raised if the route doesn't
142
+ * exist.
143
+ *
144
+ * ```ts
145
+ * urlFor.put('users.update', [1]) // { method: 'put', url: '/users/1' }
146
+ * urlFor.put('users.show', [1]) // Error: Route not found PUT@users.show
147
+ * ```
148
+ */
149
+ put<RouteIdentifier extends keyof Routes['PUT'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['PUT'][RouteIdentifier], Options>): {
150
+ method: 'PUT';
151
+ url: string;
152
+ form: {
153
+ action: string;
154
+ method: 'PUT';
155
+ };
156
+ };
157
+ /**
158
+ * Make URL for a PATCH route. An error will be raised if the route doesn't
159
+ * exist.
160
+ *
161
+ * ```ts
162
+ * urlFor.put('users.update', [1]) // { method: 'patch', url: '/users/1' }
163
+ * urlFor.put('users.show', [1]) // Error: Route not found PATCH@users.show
164
+ * ```
165
+ */
166
+ patch<RouteIdentifier extends keyof Routes['PATCH'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['PATCH'][RouteIdentifier], Options>): {
167
+ method: 'PATCH';
168
+ url: string;
169
+ form: {
170
+ action: string;
171
+ method: 'PATCH';
172
+ };
173
+ };
174
+ /**
175
+ * Make URL for a DELETE route. An error will be raised if the route doesn't
176
+ * exist.
177
+ *
178
+ * ```ts
179
+ * urlFor.delete('users.destroy', [1]) // { method: 'delete', url: '/users/1' }
180
+ * urlFor.delete('users.show', [1]) // Error: Route not found DELETE@users.show
181
+ * ```
182
+ */
183
+ delete<RouteIdentifier extends keyof Routes['DELETE'] & string>(...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes['DELETE'][RouteIdentifier], Options>): {
184
+ method: 'DELETE';
185
+ url: string;
186
+ form: {
187
+ action: string;
188
+ method: 'DELETE';
189
+ };
190
+ };
191
+ /**
192
+ * Make URL for a custom route method. An error will be raised if the route doesn't
193
+ * exist for the same method.
194
+ */
195
+ method<Method extends keyof Routes & string, RouteIdentifier extends keyof Routes[Method] & string>(method: Method, ...[identifier, params, options]: RouteBuilderArguments<RouteIdentifier, Routes[Method][RouteIdentifier], Options>): {
196
+ method: Method;
197
+ url: string;
198
+ form: {
199
+ action: string;
200
+ method: Method;
201
+ };
202
+ };
203
+ };
@@ -0,0 +1,15 @@
1
+ import { createURL, findRoute } from './helpers.ts';
2
+ import { type UrlFor, type LookupList, type ClientRouteJSON } from './types.ts';
3
+ export * from './types.ts';
4
+ export { createURL, findRoute };
5
+ /**
6
+ * Creates the URLBuilder helper
7
+ * @param router - The router instance
8
+ * @param searchParamsStringifier - Function to stringify query string parameters
9
+ * @returns URL builder function for creating URLs
10
+ */
11
+ export declare function createUrlBuilder<Routes extends LookupList>(routesLoader: {
12
+ [domain: string]: ClientRouteJSON[];
13
+ } | (() => {
14
+ [domain: string]: ClientRouteJSON[];
15
+ }), searchParamsStringifier: (qs: Record<string, any>) => string): UrlFor<Routes>;
@@ -0,0 +1,12 @@
1
+ import {
2
+ createUrlBuilder
3
+ } from "../../chunk-5PWHBE2E.js";
4
+ import {
5
+ createURL,
6
+ findRoute
7
+ } from "../../chunk-2QM3D5BN.js";
8
+ export {
9
+ createURL,
10
+ createUrlBuilder,
11
+ findRoute
12
+ };
@@ -1,37 +1,95 @@
1
1
  import type { Encryption } from '@adonisjs/encryption';
2
2
  /**
3
- * Cookie client exposes the API to parse/set AdonisJS cookies
4
- * as a client.
3
+ * Cookie client provides a unified API for parsing and setting AdonisJS cookies on the client side.
4
+ *
5
+ * This class handles different types of cookies including plain, signed, and encrypted cookies.
6
+ * It provides methods to encode/decode cookies for client-side operations and parse server responses.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const client = new CookieClient(encryption)
11
+ *
12
+ * // Encrypt a cookie value
13
+ * const encrypted = client.encrypt('sessionId', 'abc123')
14
+ *
15
+ * // Parse a cookie from server response
16
+ * const value = client.parse('sessionId', cookieValue)
17
+ * ```
5
18
  */
6
19
  export declare class CookieClient {
7
20
  #private;
21
+ /**
22
+ * Create a new instance of CookieClient
23
+ *
24
+ * @param encryption - The encryption instance for cookie operations
25
+ */
8
26
  constructor(encryption: Encryption);
9
27
  /**
10
28
  * Encrypt a key value pair to be sent in the cookie header
29
+ *
30
+ * @param key - The cookie key
31
+ * @param value - The value to encrypt
32
+ * @returns The encrypted cookie string or null if encryption fails
11
33
  */
12
34
  encrypt(key: string, value: any): string | null;
13
35
  /**
14
36
  * Sign a key value pair to be sent in the cookie header
37
+ *
38
+ * @param key - The cookie key
39
+ * @param value - The value to sign
40
+ * @returns The signed cookie string or null if signing fails
15
41
  */
16
42
  sign(key: string, value: any): string | null;
17
43
  /**
18
44
  * Encode a key value pair to be sent in the cookie header
45
+ *
46
+ * @param _ - Unused key parameter
47
+ * @param value - The value to encode
48
+ * @param stringify - Whether to stringify the value before encoding
49
+ * @returns The encoded cookie string or null if encoding fails
19
50
  */
20
51
  encode(_: string, value: any, stringify?: boolean): string | null;
21
52
  /**
22
53
  * Unsign a signed cookie value
54
+ *
55
+ * @param key - The cookie key
56
+ * @param value - The signed cookie value to unsign
57
+ * @returns The original value if valid signature, null otherwise
23
58
  */
24
59
  unsign(key: string, value: string): any;
25
60
  /**
26
61
  * Decrypt an encrypted cookie value
62
+ *
63
+ * @param key - The cookie key
64
+ * @param value - The encrypted cookie value to decrypt
65
+ * @returns The decrypted value or null if decryption fails
27
66
  */
28
67
  decrypt(key: string, value: string): any;
29
68
  /**
30
69
  * Decode an encoded cookie value
70
+ *
71
+ * @param _ - Unused key parameter
72
+ * @param value - The encoded cookie value to decode
73
+ * @param stringified - Whether the value was stringified during encoding
74
+ * @returns The decoded value or null if decoding fails
31
75
  */
32
76
  decode(_: string, value: string, stringified?: boolean): any;
33
77
  /**
34
- * Parse response cookie
78
+ * Parse a cookie value by attempting to decrypt, unsign, or decode it.
79
+ *
80
+ * This method tries different unpacking strategies in order:
81
+ * 1. Unsign if it's a signed cookie
82
+ * 2. Decrypt if it's an encrypted cookie
83
+ * 3. Decode if it's a plain encoded cookie
84
+ *
85
+ * @param key - The cookie key
86
+ * @param value - The cookie value to parse
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * const parsed = client.parse('session', 'e30.abc123def')
91
+ * // Returns the original value if successfully parsed
92
+ * ```
35
93
  */
36
94
  parse(key: string, value: any): any;
37
95
  }
@@ -1,16 +1,29 @@
1
1
  import type { Encryption } from '@adonisjs/encryption';
2
2
  /**
3
3
  * Encrypt a value to be set as cookie
4
+ *
5
+ * @param key - The cookie key used for encryption
6
+ * @param value - The value to encrypt
7
+ * @param encryption - The encryption instance
8
+ * @returns The encrypted cookie string or null if value is null/undefined
4
9
  */
5
10
  export declare function pack(key: string, value: any, encryption: Encryption): null | string;
6
11
  /**
7
12
  * Returns a boolean, if the unpack method from this module can attempt
8
13
  * to unpack encrypted value.
14
+ *
15
+ * @param encryptedValue - The encrypted value to check
16
+ * @returns True if the value can be unpacked by this module
9
17
  */
10
18
  export declare function canUnpack(encryptedValue: string): boolean;
11
19
  /**
12
20
  * Attempts to unpack the encrypted cookie value. Returns null, when fails to do so.
13
21
  * Only call this method, when `canUnpack` returns true, otherwise runtime
14
22
  * exceptions can be raised.
23
+ *
24
+ * @param key - The cookie key used for decryption
25
+ * @param encryptedValue - The encrypted value to decrypt
26
+ * @param encryption - The encryption instance
27
+ * @returns The decrypted value or null if decryption fails
15
28
  */
16
29
  export declare function unpack(key: string, encryptedValue: string, encryption: Encryption): null | any;
@@ -1,15 +1,24 @@
1
1
  /**
2
2
  * Encodes a value into a base64 url encoded string to
3
3
  * be set as cookie
4
+ *
5
+ * @param value - The value to encode
6
+ * @returns The encoded cookie string or null if value is null/undefined
4
7
  */
5
8
  export declare function pack(value: any): null | string;
6
9
  /**
7
10
  * Returns true when this `unpack` method of this module can attempt
8
11
  * to unpack the encode value.
12
+ *
13
+ * @param encodedValue - The encoded value to check
14
+ * @returns True if the value can be unpacked by this module
9
15
  */
10
16
  export declare function canUnpack(encodedValue: string): boolean;
11
17
  /**
12
18
  * Attempts to unpack the value by decoding it. Make sure to call, `canUnpack`
13
19
  * before calling this method
20
+ *
21
+ * @param encodedValue - The encoded value to decode
22
+ * @returns The decoded value or null if decoding fails
14
23
  */
15
24
  export declare function unpack(encodedValue: string): null | any;
@@ -2,15 +2,28 @@ import type { Encryption } from '@adonisjs/encryption';
2
2
  /**
3
3
  * Signs a value to be shared as a cookie. The signed output has a
4
4
  * hash to verify tampering with the original value
5
+ *
6
+ * @param key - The cookie key used for signing
7
+ * @param value - The value to sign
8
+ * @param encryption - The encryption instance
9
+ * @returns The signed cookie string or null if value is null/undefined
5
10
  */
6
11
  export declare function pack(key: string, value: any, encryption: Encryption): null | string;
7
12
  /**
8
13
  * Returns a boolean, if the unpack method from this module can attempt
9
14
  * to unpack the signed value.
15
+ *
16
+ * @param signedValue - The signed value to check
17
+ * @returns True if the value can be unpacked by this module
10
18
  */
11
19
  export declare function canUnpack(signedValue: string): boolean;
12
20
  /**
13
21
  * Attempts to unpack the signed value. Make sure to call `canUnpack` before
14
22
  * calling this method.
23
+ *
24
+ * @param key - The cookie key used for verification
25
+ * @param signedValue - The signed value to verify and unpack
26
+ * @param encryption - The encryption instance
27
+ * @returns The original value or null if verification fails
15
28
  */
16
29
  export declare function unpack(key: string, signedValue: string, encryption: Encryption): null | any;
@@ -11,27 +11,45 @@ import type { Encryption } from '@adonisjs/encryption';
11
11
  */
12
12
  export declare class CookieParser {
13
13
  #private;
14
+ /**
15
+ * Create a new instance of CookieParser
16
+ *
17
+ * @param cookieHeader - The raw cookie header string from the request
18
+ * @param encryption - The encryption instance for cookie operations
19
+ */
14
20
  constructor(cookieHeader: string, encryption: Encryption);
15
21
  /**
16
22
  * Attempts to decode a cookie by the name. When calling this method,
17
23
  * you are assuming that the cookie was just stringified in the first
18
24
  * place and not signed or encrypted.
25
+ *
26
+ * @param key - The cookie key to decode
27
+ * @param stringified - Whether the cookie value was stringified
28
+ * @returns The decoded cookie value or null if decoding fails
19
29
  */
20
30
  decode(key: string, stringified?: boolean): any | null;
21
31
  /**
22
32
  * Attempts to unsign a cookie by the name. When calling this method,
23
33
  * you are assuming that the cookie was signed in the first place.
34
+ *
35
+ * @param key - The cookie key to unsign
36
+ * @returns The original cookie value or null if unsigning fails
24
37
  */
25
38
  unsign(key: string): null | any;
26
39
  /**
27
40
  * Attempts to decrypt a cookie by the name. When calling this method,
28
41
  * you are assuming that the cookie was encrypted in the first place.
42
+ *
43
+ * @param key - The cookie key to decrypt
44
+ * @returns The decrypted cookie value or null if decryption fails
29
45
  */
30
46
  decrypt(key: string): null | any;
31
47
  /**
32
48
  * Returns an object of cookies key-value pair. Do note, the
33
49
  * cookies are not decoded, unsigned or decrypted inside this
34
50
  * list.
51
+ *
52
+ * @returns Raw cookies as key-value pairs
35
53
  */
36
54
  list(): Record<string, any>;
37
55
  }
@@ -7,6 +7,11 @@ import type { CookieOptions } from '../types/response.ts';
7
7
  */
8
8
  export declare class CookieSerializer {
9
9
  #private;
10
+ /**
11
+ * Create a new instance of CookieSerializer
12
+ *
13
+ * @param encryption - The encryption instance for cookie operations
14
+ */
10
15
  constructor(encryption: Encryption);
11
16
  /**
12
17
  * Encodes value as a plain cookie. By default, the plain value will be converted
@@ -18,11 +23,15 @@ export declare class CookieSerializer {
18
23
  * serializer.encode('name', 'virk')
19
24
  * serializer.encode('name', 'virk', { stringify: false })
20
25
  * ```
26
+ *
27
+ * @param key - The cookie key
28
+ * @param value - The value to encode
29
+ * @param options - Cookie encoding options
30
+ * @returns The serialized cookie string or null if encoding fails
21
31
  */
22
32
  encode(key: string, value: any, options?: Partial<CookieOptions & {
23
33
  /**
24
- * @depreacted
25
- * Instead use stringify option
34
+ * @depreacted Instead use stringify option
26
35
  */
27
36
  encode: boolean;
28
37
  stringify: boolean;
@@ -30,10 +39,20 @@ export declare class CookieSerializer {
30
39
  /**
31
40
  * Sign a key-value pair to a signed cookie. The signed value has a
32
41
  * verification hash attached to it to detect data tampering.
42
+ *
43
+ * @param key - The cookie key
44
+ * @param value - The value to sign
45
+ * @param options - Cookie options
46
+ * @returns The serialized signed cookie string or null if signing fails
33
47
  */
34
48
  sign(key: string, value: any, options?: Partial<CookieOptions>): string | null;
35
49
  /**
36
50
  * Encrypts a key-value pair to an encrypted cookie.
51
+ *
52
+ * @param key - The cookie key
53
+ * @param value - The value to encrypt
54
+ * @param options - Cookie options
55
+ * @returns The serialized encrypted cookie string or null if encryption fails
37
56
  */
38
57
  encrypt(key: string, value: any, options?: Partial<CookieOptions>): string | null;
39
58
  }
@@ -1,2 +1,15 @@
1
+ /**
2
+ * Debug logger instance for the AdonisJS HTTP server package.
3
+ *
4
+ * This debug logger can be enabled by setting the NODE_DEBUG environment variable
5
+ * to include 'adonisjs:http'. When enabled, it will output detailed debugging
6
+ * information about HTTP server operations including route matching, middleware
7
+ * execution, and response generation.
8
+ *
9
+ * @example
10
+ * ```bash
11
+ * NODE_DEBUG=adonisjs:http node ace serve
12
+ * ```
13
+ */
1
14
  declare const _default: import("util").DebugLogger;
2
15
  export default _default;
@@ -1,12 +1,28 @@
1
+ import { type DeepPartial } from '@poppinss/utils/types';
1
2
  import type { ServerConfig } from './types/server.ts';
2
- type DeepPartial<T> = {
3
- [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
4
- };
5
3
  type UserDefinedServerConfig = DeepPartial<Omit<ServerConfig, 'trustProxy'> & {
6
4
  trustProxy: ((address: string, distance: number) => boolean) | boolean | string;
7
5
  }>;
8
6
  /**
9
- * Define configuration for the HTTP server
7
+ * Define configuration for the HTTP server with sensible defaults.
8
+ *
9
+ * This function merges user-provided configuration with default values,
10
+ * normalizes certain properties (like cookie maxAge and trustProxy settings),
11
+ * and returns a complete ServerConfig object.
12
+ *
13
+ * @param config - User-defined server configuration options
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const config = defineConfig({
18
+ * trustProxy: true,
19
+ * cookie: {
20
+ * maxAge: '7d',
21
+ * secure: false
22
+ * },
23
+ * etag: true
24
+ * })
25
+ * ```
10
26
  */
11
27
  export declare function defineConfig(config: UserDefinedServerConfig): ServerConfig;
12
28
  export {};
@@ -1,9 +1,25 @@
1
1
  import type { LazyImport, UnWrapLazyImport } from '@poppinss/utils/types';
2
- import type { GetMiddlewareArgs, MiddlewareAsClass, ParsedGlobalMiddleware } from './types/middleware.ts';
2
+ import type { MiddlewareAsClass, GetMiddlewareArgs, ParsedGlobalMiddleware } from './types/middleware.ts';
3
3
  /**
4
- * Define an collection of named middleware. The collection gets converted
5
- * into a collection of factory functions. Calling the function returns
6
- * a reference to the executable middleware.
4
+ * Define a collection of named middleware that can be referenced by name in routes and route groups.
5
+ *
6
+ * This function converts a collection of middleware classes into factory functions that can be
7
+ * called with arguments to create middleware references. Each middleware in the collection
8
+ * becomes available as a typed function that preserves the middleware's argument signature.
9
+ *
10
+ * @param collection - Object mapping middleware names to their lazy import references
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const namedMiddleware = defineNamedMiddleware({
15
+ * auth: () => import('./middleware/auth.ts'),
16
+ * throttle: () => import('./middleware/throttle.ts')
17
+ * })
18
+ *
19
+ * // Usage in routes
20
+ * router.get('/dashboard', [namedMiddleware.auth(), handler])
21
+ * router.get('/api/data', [namedMiddleware.throttle({ max: 100 }), handler])
22
+ * ```
7
23
  */
8
24
  export declare function defineNamedMiddleware<NamedMiddleware extends Record<string, LazyImport<MiddlewareAsClass>>>(collection: NamedMiddleware): { [K in keyof NamedMiddleware]: <Args extends GetMiddlewareArgs<UnWrapLazyImport<NamedMiddleware[K]>>>(...args: Args) => {
9
25
  name: K;