@adonisjs/http-server 8.0.0-next.4 → 8.0.0-next.6

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 (56) hide show
  1. package/build/{chunk-BFGF3A5X.js → chunk-7ROFCP6L.js} +1095 -548
  2. package/build/{chunk-ASX56VAK.js → chunk-NQNHMINZ.js} +59 -0
  3. package/build/factories/http_context.d.ts +2 -1
  4. package/build/factories/http_server.d.ts +7 -0
  5. package/build/factories/main.js +31 -5
  6. package/build/factories/qs_parser_factory.d.ts +3 -2
  7. package/build/factories/request.d.ts +1 -0
  8. package/build/factories/response.d.ts +1 -0
  9. package/build/factories/router.d.ts +1 -0
  10. package/build/factories/server_factory.d.ts +1 -0
  11. package/build/factories/url_builder_factory.d.ts +1 -0
  12. package/build/index.d.ts +3 -1
  13. package/build/index.js +87 -37
  14. package/build/src/cookies/client.d.ts +35 -0
  15. package/build/src/cookies/drivers/encrypted.d.ts +13 -0
  16. package/build/src/cookies/drivers/plain.d.ts +9 -0
  17. package/build/src/cookies/drivers/signed.d.ts +13 -0
  18. package/build/src/cookies/parser.d.ts +18 -0
  19. package/build/src/cookies/serializer.d.ts +20 -0
  20. package/build/src/define_config.d.ts +1 -3
  21. package/build/src/define_middleware.d.ts +1 -1
  22. package/build/src/exception_handler.d.ts +72 -31
  23. package/build/src/helpers.d.ts +50 -0
  24. package/build/src/helpers.js +5 -1
  25. package/build/src/http_context/local_storage.d.ts +17 -0
  26. package/build/src/http_context/main.d.ts +8 -0
  27. package/build/src/qs.d.ts +14 -0
  28. package/build/src/redirect.d.ts +27 -11
  29. package/build/src/request.d.ts +109 -10
  30. package/build/src/response.d.ts +399 -203
  31. package/build/src/router/brisk.d.ts +15 -4
  32. package/build/src/router/executor.d.ts +4 -0
  33. package/build/src/router/factories/use_return_value.d.ts +5 -0
  34. package/build/src/router/group.d.ts +17 -0
  35. package/build/src/router/legacy/url_builder.d.ts +7 -0
  36. package/build/src/router/main.d.ts +72 -1
  37. package/build/src/router/matchers.d.ts +3 -0
  38. package/build/src/router/resource.d.ts +33 -0
  39. package/build/src/router/route.d.ts +8 -0
  40. package/build/src/router/signed_url_builder.d.ts +4 -8
  41. package/build/src/router/store.d.ts +9 -0
  42. package/build/src/router/url_builder.d.ts +4 -9
  43. package/build/src/server/factories/middleware_handler.d.ts +10 -1
  44. package/build/src/server/factories/route_finder.d.ts +13 -3
  45. package/build/src/server/factories/write_response.d.ts +9 -2
  46. package/build/src/server/main.d.ts +77 -23
  47. package/build/src/tracing_channels.d.ts +4 -4
  48. package/build/src/types/middleware.d.ts +33 -8
  49. package/build/src/types/qs.d.ts +5 -0
  50. package/build/src/types/request.d.ts +1 -1
  51. package/build/src/types/response.d.ts +14 -6
  52. package/build/src/types/route.d.ts +40 -17
  53. package/build/src/types/server.d.ts +26 -11
  54. package/build/src/types/tracing_channels.d.ts +21 -3
  55. package/build/src/types/url_builder.d.ts +41 -28
  56. package/package.json +15 -13
@@ -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,6 +23,11 @@ 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
  /**
@@ -30,10 +40,20 @@ export declare class CookieSerializer {
30
40
  /**
31
41
  * Sign a key-value pair to a signed cookie. The signed value has a
32
42
  * verification hash attached to it to detect data tampering.
43
+ *
44
+ * @param key - The cookie key
45
+ * @param value - The value to sign
46
+ * @param options - Cookie options
47
+ * @returns The serialized signed cookie string or null if signing fails
33
48
  */
34
49
  sign(key: string, value: any, options?: Partial<CookieOptions>): string | null;
35
50
  /**
36
51
  * Encrypts a key-value pair to an encrypted cookie.
52
+ *
53
+ * @param key - The cookie key
54
+ * @param value - The value to encrypt
55
+ * @param options - Cookie options
56
+ * @returns The serialized encrypted cookie string or null if encryption fails
37
57
  */
38
58
  encrypt(key: string, value: any, options?: Partial<CookieOptions>): string | null;
39
59
  }
@@ -1,7 +1,5 @@
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
  }>;
@@ -1,5 +1,5 @@
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
4
  * Define an collection of named middleware. The collection gets converted
5
5
  * into a collection of factory functions. Calling the function returns
@@ -17,97 +17,138 @@ import type { HttpError, StatusPageRange, StatusPageRenderer } from './types/ser
17
17
  export declare class ExceptionHandler extends Macroable {
18
18
  #private;
19
19
  /**
20
- * Whether or not to render debug info. When set to true, the errors
21
- * will have the complete error stack.
20
+ * Controls whether to include debug information in error responses
21
+ * When enabled, errors include complete stack traces and detailed debugging info
22
+ * Defaults to true in non-production environments
22
23
  */
23
24
  protected debug: boolean;
24
25
  /**
25
- * Whether or not to render status pages. When set to true, the unhandled
26
- * errors with matching status codes will be rendered using a status
27
- * page.
26
+ * Controls whether to render custom status pages for unhandled errors
27
+ * When enabled, errors with matching status codes use configured status page renderers
28
+ * Defaults to true in production environments
28
29
  */
29
30
  protected renderStatusPages: boolean;
30
31
  /**
31
- * A collection of error status code range and the view to render.
32
+ * Mapping of HTTP status code ranges to their corresponding page renderers
33
+ * Supports ranges like '400-499' or individual codes like '404'
32
34
  */
33
35
  protected statusPages: Record<StatusPageRange, StatusPageRenderer>;
34
36
  /**
35
- * Enable/disable errors reporting
37
+ * Controls whether errors should be reported to logging systems
38
+ * When disabled, errors are handled but not logged or reported
36
39
  */
37
40
  protected reportErrors: boolean;
38
41
  /**
39
- * An array of exception classes to ignore when
40
- * reporting an error
42
+ * Array of exception class constructors to exclude from error reporting
43
+ * These exceptions are handled but not logged or reported to external systems
41
44
  */
42
45
  protected ignoreExceptions: any[];
43
46
  /**
44
- * An array of HTTP status codes to ignore when reporting
45
- * an error
47
+ * Array of HTTP status codes to exclude from error reporting
48
+ * Errors with these status codes are handled but not logged
46
49
  */
47
50
  protected ignoreStatuses: number[];
48
51
  /**
49
- * An array of error codes to ignore when reporting
50
- * an error
52
+ * Array of custom error codes to exclude from error reporting
53
+ * Errors with these codes are handled but not logged
51
54
  */
52
55
  protected ignoreCodes: string[];
53
56
  /**
54
- * Error reporting context
57
+ * Provides additional context information for error reporting
58
+ * Includes request ID when available for correlation across logs
59
+ * @param ctx - HTTP context containing request information
60
+ * @returns Additional context data for error reporting
55
61
  */
56
62
  protected context(ctx: HttpContext): any;
57
63
  /**
58
- * Returns the log level for an error based upon the error
59
- * status code.
64
+ * Determines the appropriate log level based on HTTP status code
65
+ * 5xx errors are logged as 'error', 4xx as 'warn', others as 'info'
66
+ * @param error - HTTP error object with status code
67
+ * @returns {Level} Appropriate logging level for the error
60
68
  */
61
69
  protected getErrorLogLevel(error: HttpError): Level;
62
70
  /**
63
- * A boolean to control if errors should be rendered with
64
- * all the available debugging info.
71
+ * Determines whether debug information should be included in error responses
72
+ * Override this method to implement context-specific debug control
73
+ * @param _ - HTTP context (unused in base implementation)
74
+ * @returns {boolean} True if debugging should be enabled
65
75
  */
66
76
  protected isDebuggingEnabled(_: HttpContext): boolean;
67
77
  /**
68
- * Returns a boolean by checking if an error should be reported.
78
+ * Determines whether an error should be reported to logging systems
79
+ * Checks against ignore lists for exceptions, status codes, and error codes
80
+ * @param error - HTTP error to evaluate for reporting
81
+ * @returns {boolean} True if the error should be reported
69
82
  */
70
83
  protected shouldReport(error: HttpError): boolean;
71
84
  /**
72
- * Renders an error to JSON response
85
+ * Renders an error as a JSON response
86
+ * In debug mode, includes full stack trace using Youch
87
+ * @param error - HTTP error to render
88
+ * @param ctx - HTTP context for the request
73
89
  */
74
90
  renderErrorAsJSON(error: HttpError, ctx: HttpContext): Promise<void>;
75
91
  /**
76
- * Renders an error to JSON API response
92
+ * Renders an error as a JSON API compliant response
93
+ * Follows JSON API specification for error objects
94
+ * @param error - HTTP error to render
95
+ * @param ctx - HTTP context for the request
77
96
  */
78
97
  renderErrorAsJSONAPI(error: HttpError, ctx: HttpContext): Promise<void>;
79
98
  /**
80
- * Renders an error to HTML response
99
+ * Renders an error as an HTML response
100
+ * Uses status pages if configured, otherwise shows debug info or simple message
101
+ * @param error - HTTP error to render
102
+ * @param ctx - HTTP context for the request
81
103
  */
82
104
  renderErrorAsHTML(error: HttpError, ctx: HttpContext): Promise<any>;
83
105
  /**
84
- * Renders the validation error message to a JSON
85
- * response
106
+ * Renders validation error messages as a JSON response
107
+ * Returns errors in a simple format with field-specific messages
108
+ * @param error - Validation error containing messages array
109
+ * @param ctx - HTTP context for the request
86
110
  */
87
111
  renderValidationErrorAsJSON(error: HttpError, ctx: HttpContext): Promise<void>;
88
112
  /**
89
- * Renders the validation error message as per JSON API
90
- * spec
113
+ * Renders validation error messages as JSON API compliant response
114
+ * Transforms validation messages to JSON API error object format
115
+ * @param error - Validation error containing messages array
116
+ * @param ctx - HTTP context for the request
91
117
  */
92
118
  renderValidationErrorAsJSONAPI(error: HttpError, ctx: HttpContext): Promise<void>;
93
119
  /**
94
- * Renders the validation error as an HTML string
120
+ * Renders validation error messages as an HTML response
121
+ * Creates simple HTML list of field errors separated by line breaks
122
+ * @param error - Validation error containing messages array
123
+ * @param ctx - HTTP context for the request
95
124
  */
96
125
  renderValidationErrorAsHTML(error: HttpError, ctx: HttpContext): Promise<void>;
97
126
  /**
98
- * Renders the error to response
127
+ * Renders an error to the appropriate response format based on content negotiation
128
+ * Supports HTML, JSON API, and JSON formats based on Accept headers
129
+ * @param error - HTTP error to render
130
+ * @param ctx - HTTP context for the request
99
131
  */
100
132
  renderError(error: HttpError, ctx: HttpContext): Promise<any>;
101
133
  /**
102
- * Renders the validation error to response
134
+ * Renders validation errors to the appropriate response format based on content negotiation
135
+ * Supports HTML, JSON API, and JSON formats for validation error messages
136
+ * @param error - Validation error to render
137
+ * @param ctx - HTTP context for the request
103
138
  */
104
139
  renderValidationError(error: HttpError, ctx: HttpContext): Promise<void>;
105
140
  /**
106
- * Reports an error during an HTTP request
141
+ * Reports an error to logging systems if reporting is enabled
142
+ * Allows errors to self-report via their own report method if available
143
+ * @param error - Any error object to report
144
+ * @param ctx - HTTP context for additional reporting context
107
145
  */
108
146
  report(error: unknown, ctx: HttpContext): Promise<void>;
109
147
  /**
110
- * Handles the error during the HTTP request.
148
+ * Handles errors during HTTP request processing
149
+ * Delegates to error's own handle method if available, otherwise renders response
150
+ * @param error - Any error object to handle
151
+ * @param ctx - HTTP context for error handling
111
152
  */
112
153
  handle(error: unknown, ctx: HttpContext): Promise<any>;
113
154
  }
@@ -1,4 +1,6 @@
1
+ import { type Encryption } from '@adonisjs/encryption';
1
2
  import { type CookieOptions } from './types/response.ts';
3
+ import { type SignedURLOptions, type URLOptions } from './types/url_builder.ts';
2
4
  import type { RouteMatchers, RouteJSON, MatchItRouteToken } from './types/route.ts';
3
5
  import { type MiddlewareFn, type RouteHandlerInfo, type MiddlewareHandlerInfo, type ParsedGlobalMiddleware, type ParsedNamedMiddleware } from './types/middleware.ts';
4
6
  /**
@@ -34,25 +36,73 @@ export { default as mime } from 'mime-types';
34
36
  * Value (val) refers to the segment value
35
37
  *
36
38
  * end refers to be the suffix or the segment (if any)
39
+ *
40
+ * @param pattern - The route pattern to parse
41
+ * @param matchers - Optional route matchers
42
+ * @returns {MatchItRouteToken[]} Array of parsed route tokens
37
43
  */
38
44
  export declare function parseRoute(pattern: string, matchers?: RouteMatchers): MatchItRouteToken[];
45
+ /**
46
+ * Makes URL for a given route pattern using its parsed tokens. The
47
+ * tokens could be generated using the "parseRoute" method.
48
+ *
49
+ * @param pattern - The route pattern
50
+ * @param tokens - Array of parsed route tokens
51
+ * @param searchParamsStringifier - Function to stringify query parameters
52
+ * @param params - Route parameters as array or object
53
+ * @param options - URL options
54
+ * @returns {string} The generated URL
55
+ */
56
+ export declare function createURL(pattern: string, tokens: Pick<MatchItRouteToken, 'val' | 'type' | 'end'>[], searchParamsStringifier: (qs: Record<string, any>) => string, params?: any[] | {
57
+ [param: string]: any;
58
+ }, options?: URLOptions): string;
59
+ /**
60
+ * Makes signed URL for a given route pattern using its parsed tokens. The
61
+ * tokens could be generated using the "parseRoute" method.
62
+ *
63
+ * @param identifier - Route identifier
64
+ * @param tokens - Array of parsed route tokens
65
+ * @param searchParamsStringifier - Function to stringify query parameters
66
+ * @param encryption - Encryption instance for signing
67
+ * @param params - Route parameters as array or object
68
+ * @param options - Signed URL options
69
+ * @returns {string} The generated signed URL
70
+ */
71
+ export declare function createSignedURL(identifier: string, tokens: MatchItRouteToken[], searchParamsStringifier: (qs: Record<string, any>) => string, encryption: Encryption, params?: any[] | {
72
+ [param: string]: any;
73
+ }, options?: SignedURLOptions): string;
39
74
  /**
40
75
  * Match a given URI with an array of patterns and extract the params
41
76
  * from the URL. Null value is returned in case of no match
77
+ *
78
+ * @param url - The URL to match
79
+ * @param patterns - Array of route patterns to match against
80
+ * @returns {null | Record<string, string>} Extracted parameters or null if no match
42
81
  */
43
82
  export declare function matchRoute(url: string, patterns: string[]): null | Record<string, string>;
44
83
  /**
45
84
  * Serialize the value of a cookie to a string you can send via
46
85
  * set-cookie response header.
86
+ *
87
+ * @param key - Cookie name
88
+ * @param value - Cookie value
89
+ * @param options - Cookie options
90
+ * @returns {string} Serialized cookie string
47
91
  */
48
92
  export declare function serializeCookie(key: string, value: string, options?: Partial<CookieOptions>): string;
49
93
  /**
50
94
  * Returns the info about a middleware handler. In case of lazy imports, the method
51
95
  * will return the import path
96
+ *
97
+ * @param middleware - The middleware function or parsed middleware
98
+ * @returns {Promise<MiddlewareHandlerInfo>} Promise resolving to middleware handler information
52
99
  */
53
100
  export declare function middlewareInfo(middleware: MiddlewareFn | ParsedGlobalMiddleware | ParsedNamedMiddleware): Promise<MiddlewareHandlerInfo>;
54
101
  /**
55
102
  * Returns the info about a route handler. In case of lazy imports, the method
56
103
  * will return the import path.
104
+ *
105
+ * @param route - The route JSON object
106
+ * @returns {Promise<RouteHandlerInfo>} Promise resolving to route handler information
57
107
  */
58
108
  export declare function routeInfo(route: RouteJSON): Promise<RouteHandlerInfo>;
@@ -1,4 +1,6 @@
1
1
  import {
2
+ createSignedURL,
3
+ createURL,
2
4
  default as default2,
3
5
  default2 as default3,
4
6
  matchRoute,
@@ -6,8 +8,10 @@ import {
6
8
  parseRoute,
7
9
  routeInfo,
8
10
  serializeCookie
9
- } from "../chunk-ASX56VAK.js";
11
+ } from "../chunk-NQNHMINZ.js";
10
12
  export {
13
+ createSignedURL,
14
+ createURL,
11
15
  default2 as encodeUrl,
12
16
  matchRoute,
13
17
  middlewareInfo,
@@ -1,11 +1,28 @@
1
1
  import { AsyncLocalStorage } from 'node:async_hooks';
2
2
  import type { HttpContext } from './main.ts';
3
+ /**
4
+ * Async local storage for HTTP context
5
+ */
3
6
  /**
4
7
  * Async local storage for HTTP context
5
8
  */
6
9
  export declare const asyncLocalStorage: {
10
+ /**
11
+ * Check if the async local storage for the HTTP context is enabled or not
12
+ */
7
13
  isEnabled: boolean;
14
+ /**
15
+ * HTTP context storage instance for the current scope
16
+ */
8
17
  storage: null | AsyncLocalStorage<HttpContext>;
18
+ /**
19
+ * Create the storage instance. This method must be called only once.
20
+ *
21
+ * @returns {AsyncLocalStorage<HttpContext>} The created storage instance
22
+ */
9
23
  create(): AsyncLocalStorage<HttpContext>;
24
+ /**
25
+ * Destroy the create storage instance
26
+ */
10
27
  destroy(): void;
11
28
  };
@@ -50,6 +50,14 @@ export declare class HttpContext extends Macroable {
50
50
  * Route subdomains
51
51
  */
52
52
  subdomains: Record<string, any>;
53
+ /**
54
+ * Creates a new HttpContext instance
55
+ *
56
+ * @param {Request} request - The HTTP request instance
57
+ * @param {Response} response - The HTTP response instance
58
+ * @param {Logger} logger - The logger instance
59
+ * @param {ContainerResolver<any>} containerResolver - The IoC container resolver
60
+ */
53
61
  constructor(request: Request, response: Response, logger: Logger, containerResolver: ContainerResolver<any>);
54
62
  /**
55
63
  * A helper to see top level properties on the context object
package/build/src/qs.d.ts CHANGED
@@ -5,7 +5,21 @@ import { type QSParserConfig } from './types/qs.ts';
5
5
  */
6
6
  export declare class Qs {
7
7
  #private;
8
+ /**
9
+ * Creates a new query string parser instance with the provided configuration
10
+ * @param config - Configuration object with parse and stringify options
11
+ */
8
12
  constructor(config: QSParserConfig);
13
+ /**
14
+ * Parses a query string into a JavaScript object using the configured options
15
+ * @param value - Query string to parse (e.g., "foo=bar&baz=qux")
16
+ * @returns Parsed object representation of the query string
17
+ */
9
18
  parse: (value: string) => import("qs").ParsedQs;
19
+ /**
20
+ * Converts a JavaScript object into a query string using the configured options
21
+ * @param value - Object to convert to query string
22
+ * @returns Stringified query string representation of the object
23
+ */
10
24
  stringify: (value: any) => string;
11
25
  }
@@ -2,40 +2,56 @@ import type { IncomingMessage } from 'node:http';
2
2
  import type { Qs } from './qs.ts';
3
3
  import type { Response } from './response.ts';
4
4
  import type { Router } from './router/main.ts';
5
- import type { RoutesList, URLOptions, GetRoutesForMethod, RouteBuilderArguments } from './types/url_builder.ts';
5
+ import type { RoutesList, LookupList, URLOptions, GetRoutesForMethod, RouteBuilderArguments } from './types/url_builder.ts';
6
6
  /**
7
7
  * Exposes the API to construct redirect routes
8
8
  */
9
9
  export declare class Redirect {
10
10
  #private;
11
+ /**
12
+ * Creates a new Redirect instance for handling HTTP redirects
13
+ * @param request - Node.js incoming HTTP request
14
+ * @param response - AdonisJS response instance
15
+ * @param router - AdonisJS router instance
16
+ * @param qs - Query string parser instance
17
+ */
11
18
  constructor(request: IncomingMessage, response: Response, router: Router, qs: Qs);
12
19
  /**
13
- * Set a custom status code.
20
+ * Sets a custom HTTP status code for the redirect response
21
+ * @param statusCode - HTTP status code to use (e.g., 301, 302, 307)
22
+ * @returns {this} The Redirect instance for method chaining
14
23
  */
15
24
  status(statusCode: number): this;
16
25
  /**
17
- * Clearing query string values added using the
18
- * "withQs" method
26
+ * Clears any query string values previously added using the withQs method
27
+ * @returns {this} The Redirect instance for method chaining
19
28
  */
20
29
  clearQs(): this;
21
30
  /**
22
- * Define query string for the redirect. Not passing
23
- * any value will forward the current request query
24
- * string.
31
+ * Defines query string parameters for the redirect URL
32
+ * - No arguments: forwards current request query string
33
+ * - Object argument: adds multiple key-value pairs
34
+ * - String arguments: adds single key-value pair
35
+ * @param name - Query parameter name or object of parameters
36
+ * @param value - Value for the query parameter (when name is string)
37
+ * @returns {this} The Redirect instance for method chaining
25
38
  */
26
39
  withQs(): this;
27
40
  withQs(values: Record<string, any>): this;
28
41
  withQs(name: string, value: any): this;
29
42
  /**
30
- * Redirect to the previous path.
43
+ * Redirects to the previous path using the Referer header
44
+ * Falls back to '/' if no referrer is found
31
45
  */
32
46
  back(): void;
33
47
  /**
34
- * Redirect the request using a route identifier.
48
+ * Redirects to a route using its identifier (name, pattern, or handler reference)
49
+ * @param args - Route identifier, parameters, and options for URL building
35
50
  */
36
- toRoute<Identifier extends keyof GetRoutesForMethod<'GET'> & string>(...args: RouteBuilderArguments<RoutesList, Identifier, 'GET', URLOptions>): void;
51
+ toRoute<Identifier extends keyof GetRoutesForMethod<RoutesList, 'GET'> & string>(...args: RoutesList extends LookupList ? RouteBuilderArguments<Identifier, RoutesList['GET'][Identifier], URLOptions> : []): void;
37
52
  /**
38
- * Redirect the request using a path.
53
+ * Redirects to a specific URL path
54
+ * @param url - Target URL path for redirection
39
55
  */
40
56
  toPath(url: string): void;
41
57
  }