@adonisjs/http-server 8.0.0-next.0 → 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.
- package/build/chunk-2QM3D5BN.js +87 -0
- package/build/chunk-5PWHBE2E.js +128 -0
- package/build/chunk-QDK57QGB.js +1176 -0
- package/build/{chunk-VYBTM3NC.js → chunk-YBLFT4O6.js} +1161 -1719
- package/build/factories/http_context.d.ts +5 -4
- package/build/factories/http_server.d.ts +7 -0
- package/build/factories/main.d.ts +6 -6
- package/build/factories/main.js +33 -5
- package/build/factories/qs_parser_factory.d.ts +5 -4
- package/build/factories/request.d.ts +3 -2
- package/build/factories/response.d.ts +4 -3
- package/build/factories/router.d.ts +2 -1
- package/build/factories/server_factory.d.ts +3 -2
- package/build/factories/url_builder_factory.d.ts +3 -2
- package/build/index.d.ts +19 -16
- package/build/index.js +97 -42
- package/build/src/client/helpers.d.ts +37 -0
- package/build/src/client/types.d.ts +88 -66
- package/build/src/client/url_builder.d.ts +12 -10
- package/build/src/client/url_builder.js +12 -0
- package/build/src/cookies/client.d.ts +61 -3
- package/build/src/cookies/drivers/encrypted.d.ts +13 -0
- package/build/src/cookies/drivers/plain.d.ts +9 -0
- package/build/src/cookies/drivers/signed.d.ts +13 -0
- package/build/src/cookies/parser.d.ts +18 -0
- package/build/src/cookies/serializer.d.ts +22 -3
- package/build/src/debug.d.ts +13 -0
- package/build/src/define_config.d.ts +21 -5
- package/build/src/define_middleware.d.ts +20 -4
- package/build/src/errors.d.ts +67 -10
- package/build/src/exception_handler.d.ts +95 -41
- package/build/src/helpers.d.ts +60 -4
- package/build/src/helpers.js +9 -1
- package/build/src/http_context/local_storage.d.ts +18 -1
- package/build/src/http_context/main.d.ts +71 -13
- package/build/src/qs.d.ts +31 -3
- package/build/src/redirect.d.ts +87 -16
- package/build/src/request.d.ts +121 -15
- package/build/src/response.d.ts +421 -208
- package/build/src/response_status.d.ts +14 -0
- package/build/src/router/brisk.d.ts +18 -7
- package/build/src/router/executor.d.ts +7 -3
- package/build/src/router/factories/use_return_value.d.ts +6 -1
- package/build/src/router/group.d.ts +23 -6
- package/build/src/router/legacy/url_builder.d.ts +15 -15
- package/build/src/router/main.d.ts +133 -20
- package/build/src/router/matchers.d.ts +3 -0
- package/build/src/router/resource.d.ts +37 -5
- package/build/src/router/route.d.ts +30 -6
- package/build/src/router/signed_url_builder.d.ts +7 -10
- package/build/src/router/store.d.ts +10 -2
- package/build/src/server/factories/middleware_handler.d.ts +12 -3
- package/build/src/server/factories/route_finder.d.ts +16 -6
- package/build/src/server/factories/write_response.d.ts +10 -3
- package/build/src/server/main.d.ts +83 -29
- package/build/src/tracing_channels.d.ts +4 -4
- package/build/src/types/main.d.ts +1 -1
- package/build/src/types/middleware.d.ts +35 -10
- package/build/src/types/qs.d.ts +5 -0
- package/build/src/types/request.d.ts +1 -1
- package/build/src/types/response.d.ts +14 -6
- package/build/src/types/route.d.ts +53 -51
- package/build/src/types/server.d.ts +30 -15
- package/build/src/types/tracing_channels.d.ts +24 -6
- package/build/src/types/url_builder.d.ts +22 -0
- package/build/src/utils.d.ts +76 -11
- package/package.json +29 -30
- package/build/chunk-ASX56VAK.js +0 -76
- package/build/client.cjs +0 -232
- package/build/client.d.cts +0 -258
- package/build/client.d.ts +0 -258
- package/build/client.js +0 -229
- package/build/src/client/main.d.ts +0 -3
- package/build/src/client/router.d.ts +0 -68
|
@@ -1,15 +1,37 @@
|
|
|
1
1
|
import Macroable from '@poppinss/macroable';
|
|
2
2
|
import type { Application } from '@adonisjs/application';
|
|
3
3
|
import type { Constructor, LazyImport, OneOrMore } from '@poppinss/utils/types';
|
|
4
|
-
import {
|
|
5
|
-
import type {
|
|
6
|
-
import type { RouteFn, RouteJSON, RouteMatchers, StoreRouteMiddleware, GetControllerHandlers } from '../types/route.js';
|
|
4
|
+
import type { MiddlewareFn, ParsedNamedMiddleware, ParsedGlobalMiddleware } from '../types/middleware.ts';
|
|
5
|
+
import type { RouteFn, RouteJSON, RouteMatcher, RouteMatchers, StoreRouteMiddleware, GetControllerHandlers } from '../types/route.ts';
|
|
7
6
|
/**
|
|
8
|
-
* The
|
|
9
|
-
*
|
|
7
|
+
* The Route class provides a fluent API for constructing and configuring HTTP routes.
|
|
8
|
+
*
|
|
9
|
+
* Routes define how HTTP requests are handled by mapping URL patterns and HTTP methods
|
|
10
|
+
* to controller actions or inline handlers. This class supports middleware application,
|
|
11
|
+
* parameter validation, naming, and various other route-specific configurations.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const route = new Route(app, middleware, {
|
|
16
|
+
* pattern: '/users/:id',
|
|
17
|
+
* methods: ['GET'],
|
|
18
|
+
* handler: 'UsersController.show'
|
|
19
|
+
* })
|
|
20
|
+
*
|
|
21
|
+
* route
|
|
22
|
+
* .where('id', /^[0-9]+$/)
|
|
23
|
+
* .middleware(['auth'])
|
|
24
|
+
* .as('users.show')
|
|
25
|
+
* ```
|
|
10
26
|
*/
|
|
11
27
|
export declare class Route<Controller extends Constructor<any> = any> extends Macroable {
|
|
12
28
|
#private;
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new Route instance
|
|
31
|
+
* @param app - The AdonisJS application instance
|
|
32
|
+
* @param routerMiddleware - Array of global middleware registered on the router
|
|
33
|
+
* @param options - Configuration options for the route
|
|
34
|
+
*/
|
|
13
35
|
constructor(app: Application<any>, routerMiddleware: ParsedGlobalMiddleware[], options: {
|
|
14
36
|
pattern: string;
|
|
15
37
|
methods: string[];
|
|
@@ -34,6 +56,8 @@ export declare class Route<Controller extends Constructor<any> = any> extends Ma
|
|
|
34
56
|
/**
|
|
35
57
|
* Define prefix for the route. Calling this method multiple times
|
|
36
58
|
* applies multiple prefixes in the reverse order.
|
|
59
|
+
* @param prefix - The prefix to add to the route
|
|
60
|
+
* @returns Current Route instance for method chaining
|
|
37
61
|
*/
|
|
38
62
|
prefix(prefix: string): this;
|
|
39
63
|
/**
|
|
@@ -50,7 +74,7 @@ export declare class Route<Controller extends Constructor<any> = any> extends Ma
|
|
|
50
74
|
*/
|
|
51
75
|
use(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this;
|
|
52
76
|
/**
|
|
53
|
-
* @
|
|
77
|
+
* Alias for {@link Route.use}
|
|
54
78
|
*/
|
|
55
79
|
middleware(middleware: OneOrMore<MiddlewareFn | ParsedNamedMiddleware>): this;
|
|
56
80
|
/**
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import type { Encryption } from '@adonisjs/encryption';
|
|
2
|
-
import { type
|
|
3
|
-
import { type UrlFor, type LookupList, type
|
|
4
|
-
/**
|
|
5
|
-
* Makes signed URL for a given route pattern. The route pattern could be an
|
|
6
|
-
* identifier or an array of tokens.
|
|
7
|
-
*/
|
|
8
|
-
export declare function createSignedURL(identifier: string, tokens: MatchItRouteToken[], searchParamsStringifier: (qs: Record<string, any>) => string, encryption: Encryption, params?: any[] | {
|
|
9
|
-
[param: string]: any;
|
|
10
|
-
}, options?: SignedURLOptions): string;
|
|
2
|
+
import { type Router } from './main.ts';
|
|
3
|
+
import { type UrlFor, type LookupList, type SignedURLOptions } from '../types/url_builder.ts';
|
|
11
4
|
/**
|
|
12
5
|
* Creates the URLBuilder helper for making signed URLs
|
|
6
|
+
* @param router - The router instance
|
|
7
|
+
* @param encryption - Encryption service for signing URLs
|
|
8
|
+
* @param searchParamsStringifier - Function to stringify query string parameters
|
|
9
|
+
* @returns URL builder function for creating signed URLs
|
|
13
10
|
*/
|
|
14
|
-
export declare function createSignedUrlBuilder<Routes extends LookupList>(router:
|
|
11
|
+
export declare function createSignedUrlBuilder<Routes extends LookupList>(router: Router, encryption: Encryption, searchParamsStringifier: (qs: Record<string, any>) => string): UrlFor<Routes, SignedURLOptions>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { RouteJSON, MatchedRoute, StoreRoutesTree } from '../types/route.
|
|
2
|
-
import { type MatchItRouteToken } from '../client/types.ts';
|
|
1
|
+
import type { RouteJSON, MatchedRoute, StoreRoutesTree, MatchItRouteToken } from '../types/route.ts';
|
|
3
2
|
/**
|
|
4
3
|
* Store class is used to store a list of routes, along side with their tokens
|
|
5
4
|
* to match the URLs.
|
|
@@ -45,6 +44,8 @@ export declare class RoutesStore {
|
|
|
45
44
|
* }
|
|
46
45
|
* })
|
|
47
46
|
* ```
|
|
47
|
+
* @param route - The route to add to the store
|
|
48
|
+
* @returns Current RoutesStore instance for method chaining
|
|
48
49
|
*/
|
|
49
50
|
add(route: RouteJSON): this;
|
|
50
51
|
/**
|
|
@@ -55,6 +56,11 @@ export declare class RoutesStore {
|
|
|
55
56
|
* The domain parameter has to be a registered pattern and not the fully
|
|
56
57
|
* qualified runtime domain. You must call `matchDomain` first to fetch
|
|
57
58
|
* the pattern for qualified domain
|
|
59
|
+
* @param url - The URL to match
|
|
60
|
+
* @param method - HTTP method
|
|
61
|
+
* @param shouldDecodeParam - Whether to decode parameters
|
|
62
|
+
* @param domain - Optional domain tokens and hostname
|
|
63
|
+
* @returns Matched route or null if no match found
|
|
58
64
|
*/
|
|
59
65
|
match(url: string, method: string, shouldDecodeParam: boolean, domain?: {
|
|
60
66
|
tokens: MatchItRouteToken[];
|
|
@@ -62,6 +68,8 @@ export declare class RoutesStore {
|
|
|
62
68
|
}): null | MatchedRoute;
|
|
63
69
|
/**
|
|
64
70
|
* Match hostname against registered domains.
|
|
71
|
+
* @param hostname - The hostname to match
|
|
72
|
+
* @returns Array of matched domain tokens
|
|
65
73
|
*/
|
|
66
74
|
matchDomain(hostname?: string | null): MatchItRouteToken[];
|
|
67
75
|
}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import type { ContainerResolver } from '@adonisjs/fold';
|
|
2
2
|
import type { NextFn } from '@poppinss/middleware/types';
|
|
3
|
-
import type { HttpContext } from '../../http_context/main.
|
|
4
|
-
import { type ParsedGlobalMiddleware } from '../../types/middleware.
|
|
3
|
+
import type { HttpContext } from '../../http_context/main.ts';
|
|
4
|
+
import { type ParsedGlobalMiddleware } from '../../types/middleware.ts';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Creates a middleware execution handler that invokes middleware functions with tracing support
|
|
7
|
+
*
|
|
8
|
+
* This factory function returns a middleware execution handler that:
|
|
9
|
+
* - Executes middleware with debug logging
|
|
10
|
+
* - Provides distributed tracing through tracing channels
|
|
11
|
+
* - Passes the container resolver, HTTP context, and next function to middleware
|
|
12
|
+
*
|
|
13
|
+
* @param resolver - Container resolver for dependency injection
|
|
14
|
+
* @param ctx - HTTP context containing request/response data
|
|
15
|
+
* @returns Middleware execution function
|
|
7
16
|
*/
|
|
8
17
|
export declare function middlewareHandler(resolver: ContainerResolver<any>, ctx: HttpContext): (fn: ParsedGlobalMiddleware, next: NextFn) => Promise<any>;
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import type { ContainerResolver } from '@adonisjs/fold';
|
|
2
|
-
import type { Router } from '../../router/main.
|
|
3
|
-
import type { HttpContext } from '../../http_context/main.
|
|
4
|
-
import type { ServerErrorHandler } from '../../types/server.
|
|
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
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Creates a route finder function that matches HTTP requests to registered routes
|
|
7
|
+
*
|
|
8
|
+
* This factory function returns a route handler that:
|
|
9
|
+
* - Matches incoming requests against registered routes
|
|
10
|
+
* - Extracts route parameters and subdomains
|
|
11
|
+
* - Executes the matched route's handler and middleware
|
|
12
|
+
* - Throws E_ROUTE_NOT_FOUND error for unmatched requests
|
|
13
|
+
*
|
|
14
|
+
* @param router - Router instance containing registered routes
|
|
15
|
+
* @param resolver - Container resolver for dependency injection
|
|
16
|
+
* @param ctx - HTTP context containing request/response data
|
|
17
|
+
* @param errorResponder - Error handler for route execution errors
|
|
18
|
+
* @returns Route execution function
|
|
9
19
|
*/
|
|
10
20
|
export declare function routeFinder(router: Router, resolver: ContainerResolver<any>, ctx: HttpContext, errorResponder: ServerErrorHandler['handle']): () => any;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import type { HttpContext } from '../../http_context/main.
|
|
1
|
+
import type { HttpContext } from '../../http_context/main.ts';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Creates a response writer function that finalizes HTTP responses with error handling
|
|
4
|
+
*
|
|
5
|
+
* This factory function returns a response finalizer that:
|
|
6
|
+
* - Calls the response.finish() method to send the response
|
|
7
|
+
* - Catches serialization errors and sends a 500 error response
|
|
8
|
+
* - Logs fatal errors for debugging and monitoring
|
|
9
|
+
*
|
|
10
|
+
* @param ctx - HTTP context containing the response to finalize
|
|
11
|
+
* @returns Response finalization function
|
|
5
12
|
*/
|
|
6
13
|
export declare function writeResponse(ctx: HttpContext): () => void;
|
|
@@ -6,81 +6,135 @@ import type { Application } from '@adonisjs/application';
|
|
|
6
6
|
import type { EmitterLike } from '@adonisjs/events/types';
|
|
7
7
|
import { type ContainerResolver } from '@adonisjs/fold';
|
|
8
8
|
import type { ServerResponse, IncomingMessage, Server as HttpServer } from 'node:http';
|
|
9
|
-
import type { MiddlewareAsClass, ParsedGlobalMiddleware } from '../types/middleware.
|
|
10
|
-
import type { ServerConfig, HttpServerEvents, ErrorHandlerAsAClass, TestingMiddlewarePipeline } from '../types/server.
|
|
11
|
-
import { Request } from '../request.
|
|
12
|
-
import { Response } from '../response.
|
|
13
|
-
import { Router } from '../router/main.
|
|
14
|
-
import { HttpContext } from '../http_context/main.
|
|
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
|
-
* The
|
|
17
|
-
*
|
|
16
|
+
* The Server class provides the core HTTP server implementation for AdonisJS.
|
|
17
|
+
*
|
|
18
|
+
* It handles incoming HTTP requests by processing them through middleware pipelines,
|
|
19
|
+
* routing them to appropriate handlers, and managing response generation. The server
|
|
20
|
+
* supports custom error handling, middleware registration, and various Node.js HTTP
|
|
21
|
+
* server configurations.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const server = new Server(app, encryption, emitter, logger, config)
|
|
26
|
+
* server.use([AuthMiddleware, CorsMiddleware])
|
|
27
|
+
* server.errorHandler(() => import('./error_handler.ts'))
|
|
28
|
+
* await server.boot()
|
|
29
|
+
*
|
|
30
|
+
* http.createServer(server.handle.bind(server))
|
|
31
|
+
* ```
|
|
18
32
|
*/
|
|
19
33
|
export declare class Server {
|
|
20
34
|
#private;
|
|
21
35
|
/**
|
|
22
|
-
*
|
|
36
|
+
* Indicates whether the server has completed its boot process
|
|
23
37
|
*/
|
|
24
38
|
get booted(): boolean;
|
|
25
39
|
/**
|
|
26
|
-
*
|
|
40
|
+
* Indicates whether async local storage is enabled for request context
|
|
27
41
|
*/
|
|
28
42
|
get usingAsyncLocalStorage(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a new Server instance
|
|
45
|
+
*
|
|
46
|
+
* @param app - AdonisJS application instance
|
|
47
|
+
* @param encryption - Encryption service for secure operations
|
|
48
|
+
* @param emitter - Event emitter for server lifecycle events
|
|
49
|
+
* @param logger - Logger instance for server operations
|
|
50
|
+
* @param config - Server configuration settings
|
|
51
|
+
*/
|
|
29
52
|
constructor(app: Application<any>, encryption: Encryption, emitter: EmitterLike<HttpServerEvents>, logger: Logger, config: ServerConfig);
|
|
30
53
|
/**
|
|
31
|
-
* Creates a pipeline
|
|
54
|
+
* Creates a testing middleware pipeline for unit/integration testing
|
|
55
|
+
*
|
|
56
|
+
* @param middleware - Array of middleware classes to include in pipeline
|
|
57
|
+
* @returns TestingMiddlewarePipeline instance for test execution
|
|
32
58
|
*/
|
|
33
59
|
pipeline(middleware: MiddlewareAsClass[]): TestingMiddlewarePipeline;
|
|
34
60
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* of middleware
|
|
61
|
+
* Registers global middleware to run on all incoming HTTP requests
|
|
62
|
+
*
|
|
63
|
+
* @param middleware - Array of lazy-imported middleware classes
|
|
64
|
+
* @returns The Server instance for method chaining
|
|
38
65
|
*/
|
|
39
66
|
use(middleware: LazyImport<MiddlewareAsClass>[]): this;
|
|
40
67
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
68
|
+
* Registers a custom error handler for HTTP request processing
|
|
69
|
+
*
|
|
70
|
+
* @param handler - Lazy import of the error handler class
|
|
71
|
+
* @returns The Server instance for method chaining
|
|
43
72
|
*/
|
|
44
73
|
errorHandler(handler: LazyImport<ErrorHandlerAsAClass>): this;
|
|
45
74
|
/**
|
|
46
|
-
*
|
|
75
|
+
* Initializes the server by compiling middleware, committing routes, and resolving handlers
|
|
47
76
|
*
|
|
48
|
-
*
|
|
49
|
-
* -
|
|
77
|
+
* Performs the following operations:
|
|
78
|
+
* - Compiles the middleware stack
|
|
79
|
+
* - Commits registered routes to the router
|
|
80
|
+
* - Resolves and instantiates the custom error handler
|
|
50
81
|
*/
|
|
51
82
|
boot(): Promise<void>;
|
|
52
83
|
/**
|
|
53
|
-
*
|
|
84
|
+
* Configures the underlying Node.js HTTP/HTTPS server with timeout settings
|
|
85
|
+
*
|
|
86
|
+
* @param server - Node.js HTTP or HTTPS server instance
|
|
54
87
|
*/
|
|
55
88
|
setNodeServer(server: HttpServer | HttpsServer): void;
|
|
56
89
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
90
|
+
* Gets the underlying Node.js HTTP/HTTPS server instance
|
|
91
|
+
*
|
|
92
|
+
* @returns The configured server instance or undefined if not set
|
|
59
93
|
*/
|
|
60
94
|
getNodeServer(): HttpServer<typeof IncomingMessage, typeof ServerResponse> | HttpsServer<typeof IncomingMessage, typeof ServerResponse> | undefined;
|
|
61
95
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
96
|
+
* Gets the router instance used for route registration and matching
|
|
97
|
+
*
|
|
98
|
+
* @returns The Router instance
|
|
64
99
|
*/
|
|
65
100
|
getRouter(): Router;
|
|
66
101
|
/**
|
|
67
|
-
* Creates
|
|
102
|
+
* Creates a Request instance from Node.js request/response objects
|
|
103
|
+
*
|
|
104
|
+
* @param req - Node.js IncomingMessage
|
|
105
|
+
* @param res - Node.js ServerResponse
|
|
106
|
+
* @returns New Request instance
|
|
68
107
|
*/
|
|
69
108
|
createRequest(req: IncomingMessage, res: ServerResponse): Request;
|
|
70
109
|
/**
|
|
71
|
-
* Creates
|
|
110
|
+
* Creates a Response instance from Node.js request/response objects
|
|
111
|
+
*
|
|
112
|
+
* @param req - Node.js IncomingMessage
|
|
113
|
+
* @param res - Node.js ServerResponse
|
|
114
|
+
* @returns New Response instance
|
|
72
115
|
*/
|
|
73
116
|
createResponse(req: IncomingMessage, res: ServerResponse): Response;
|
|
74
117
|
/**
|
|
75
|
-
* Creates an instance
|
|
118
|
+
* Creates an HttpContext instance with request-specific logger
|
|
119
|
+
*
|
|
120
|
+
* @param request - Request instance
|
|
121
|
+
* @param response - Response instance
|
|
122
|
+
* @param resolver - Container resolver for dependency injection
|
|
123
|
+
* @returns New HttpContext instance
|
|
76
124
|
*/
|
|
77
125
|
createHttpContext(request: Request, response: Response, resolver: ContainerResolver<any>): HttpContext;
|
|
78
126
|
/**
|
|
79
|
-
*
|
|
127
|
+
* Gets the list of registered global middleware
|
|
128
|
+
*
|
|
129
|
+
* @returns Array of parsed global middleware
|
|
80
130
|
*/
|
|
81
131
|
getMiddlewareList(): ParsedGlobalMiddleware[];
|
|
82
132
|
/**
|
|
83
|
-
*
|
|
133
|
+
* Handles an incoming HTTP request by creating context and processing through pipeline
|
|
134
|
+
*
|
|
135
|
+
* @param req - Node.js IncomingMessage
|
|
136
|
+
* @param res - Node.js ServerResponse
|
|
137
|
+
* @returns Promise that resolves when request processing is complete
|
|
84
138
|
*/
|
|
85
139
|
handle(req: IncomingMessage, res: ServerResponse): Promise<any>;
|
|
86
140
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import diagnostics_channel from 'node:diagnostics_channel';
|
|
2
|
-
import type { MiddlewareTracingData } from './types/tracing_channels.
|
|
2
|
+
import type { MiddlewareTracingData, HTTPRequestTracingData, RouteHandlerTracingData } from './types/tracing_channels.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Traces every HTTP request handled by the {@link Server} class.
|
|
5
5
|
*/
|
|
6
|
-
export declare const httpRequest: diagnostics_channel.TracingChannel<"adonisjs
|
|
6
|
+
export declare const httpRequest: diagnostics_channel.TracingChannel<"adonisjs.http.request", HTTPRequestTracingData>;
|
|
7
7
|
/**
|
|
8
8
|
* Traces middleware executed during the HTTP request
|
|
9
9
|
*/
|
|
10
|
-
export declare const httpMiddleware: diagnostics_channel.TracingChannel<"adonisjs
|
|
10
|
+
export declare const httpMiddleware: diagnostics_channel.TracingChannel<"adonisjs.http.middleware", MiddlewareTracingData>;
|
|
11
11
|
/**
|
|
12
12
|
* Traces the exception handler that converts errors into HTTP responses
|
|
13
13
|
*/
|
|
@@ -15,7 +15,7 @@ export declare const httpExceptionHandler: diagnostics_channel.TracingChannel<"a
|
|
|
15
15
|
/**
|
|
16
16
|
* Traces route handler executed during the HTTP request
|
|
17
17
|
*/
|
|
18
|
-
export declare const httpRouteHandler: diagnostics_channel.TracingChannel<"adonisjs
|
|
18
|
+
export declare const httpRouteHandler: diagnostics_channel.TracingChannel<"adonisjs.http.route.handler", RouteHandlerTracingData>;
|
|
19
19
|
/**
|
|
20
20
|
* Traces non-stream and non-file download responses written by the AdonisJS
|
|
21
21
|
* response class
|
|
@@ -1,70 +1,95 @@
|
|
|
1
1
|
import type { ContainerResolver } from '@adonisjs/fold';
|
|
2
2
|
import type { NextFn } from '@poppinss/middleware/types';
|
|
3
3
|
import type { Constructor, LazyImport } from '@poppinss/utils/types';
|
|
4
|
-
import type { HttpContext } from '../http_context/main.
|
|
4
|
+
import type { HttpContext } from '../http_context/main.ts';
|
|
5
|
+
export { NextFn };
|
|
5
6
|
/**
|
|
6
|
-
* Middleware represented as a class
|
|
7
|
+
* Middleware represented as a class constructor that implements a handle method
|
|
7
8
|
*/
|
|
8
9
|
export type MiddlewareAsClass = Constructor<{
|
|
9
10
|
handle: (ctx: HttpContext, next: NextFn, args?: any) => any;
|
|
10
11
|
}>;
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
* Utility type to check if a union type includes undefined or null values
|
|
13
14
|
*/
|
|
14
15
|
type HasUndefined<T> = T extends NonNullable<T> ? true : false;
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* Extracts and returns the argument types accepted by a middleware's handle method
|
|
18
|
+
* Returns an empty array if no args, otherwise returns the args type as a tuple
|
|
17
19
|
*/
|
|
18
20
|
export type GetMiddlewareArgs<Middleware extends MiddlewareAsClass> = Parameters<InstanceType<Middleware>['handle']>[2] extends undefined ? [] : HasUndefined<Parameters<InstanceType<Middleware>['handle']>[2]> extends true ? [Parameters<InstanceType<Middleware>['handle']>[2]] : [Parameters<InstanceType<Middleware>['handle']>[2]?];
|
|
19
21
|
/**
|
|
20
|
-
*
|
|
22
|
+
* Middleware defined as a function that accepts HTTP context and next function
|
|
21
23
|
*/
|
|
22
24
|
export type MiddlewareFn = (ctx: HttpContext, next: NextFn) => any;
|
|
23
25
|
/**
|
|
24
|
-
*
|
|
26
|
+
* Representation of a parsed global middleware with its metadata and execution handler
|
|
25
27
|
*/
|
|
26
28
|
export type ParsedGlobalMiddleware = {
|
|
29
|
+
/** Optional name for the middleware */
|
|
27
30
|
name?: string;
|
|
31
|
+
/** Reference to the middleware class or lazy import */
|
|
28
32
|
reference: LazyImport<MiddlewareAsClass> | MiddlewareAsClass;
|
|
33
|
+
/** Handler function that executes the middleware */
|
|
29
34
|
handle: (resolver: ContainerResolver<any>, ...args: [ctx: HttpContext, next: NextFn, params?: any]) => any;
|
|
30
35
|
};
|
|
31
36
|
/**
|
|
32
|
-
*
|
|
37
|
+
* Representation of a parsed named middleware with its metadata, arguments and execution handler
|
|
33
38
|
*/
|
|
34
39
|
export type ParsedNamedMiddleware = {
|
|
40
|
+
/** Name identifier for the middleware */
|
|
35
41
|
name: string;
|
|
42
|
+
/** Reference to the middleware class or lazy import */
|
|
36
43
|
reference: LazyImport<MiddlewareAsClass> | MiddlewareAsClass;
|
|
44
|
+
/** Handler function that executes the middleware */
|
|
37
45
|
handle: ParsedGlobalMiddleware['handle'];
|
|
46
|
+
/** Arguments to pass to the middleware */
|
|
38
47
|
args: any;
|
|
39
48
|
};
|
|
40
49
|
/**
|
|
41
|
-
*
|
|
50
|
+
* Information node describing different types of middleware handlers and their metadata
|
|
42
51
|
*/
|
|
43
52
|
export type MiddlewareHandlerInfo = {
|
|
53
|
+
/** Type identifier for closure middleware */
|
|
44
54
|
type: 'closure';
|
|
55
|
+
/** Name of the closure middleware */
|
|
45
56
|
name: string;
|
|
46
57
|
} | {
|
|
58
|
+
/** Type identifier for named middleware */
|
|
47
59
|
type: 'named';
|
|
60
|
+
/** Name of the named middleware */
|
|
48
61
|
name: string;
|
|
62
|
+
/** Arguments to pass to the middleware */
|
|
49
63
|
args: any | undefined;
|
|
64
|
+
/** Method name on the middleware class */
|
|
50
65
|
method: string;
|
|
66
|
+
/** Module name or file path for the middleware */
|
|
51
67
|
moduleNameOrPath: string;
|
|
52
68
|
} | {
|
|
69
|
+
/** Type identifier for global middleware */
|
|
53
70
|
type: 'global';
|
|
71
|
+
/** Optional name for the global middleware */
|
|
54
72
|
name?: string | undefined;
|
|
73
|
+
/** Method name on the middleware class */
|
|
55
74
|
method: string;
|
|
75
|
+
/** Module name or file path for the middleware */
|
|
56
76
|
moduleNameOrPath: string;
|
|
57
77
|
};
|
|
58
78
|
/**
|
|
59
|
-
*
|
|
79
|
+
* Information node describing different types of route handlers and their metadata
|
|
60
80
|
*/
|
|
61
81
|
export type RouteHandlerInfo = {
|
|
82
|
+
/** Type identifier for closure route handler */
|
|
62
83
|
type: 'closure';
|
|
84
|
+
/** Name of the closure handler */
|
|
63
85
|
name: string;
|
|
86
|
+
/** Optional arguments for the closure */
|
|
64
87
|
args?: string;
|
|
65
88
|
} | {
|
|
89
|
+
/** Type identifier for controller route handler */
|
|
66
90
|
type: 'controller';
|
|
91
|
+
/** Method name on the controller class */
|
|
67
92
|
method: string;
|
|
93
|
+
/** Module name or file path for the controller */
|
|
68
94
|
moduleNameOrPath: string;
|
|
69
95
|
};
|
|
70
|
-
export {};
|
package/build/src/types/qs.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for query string parsing and stringification
|
|
3
|
+
*/
|
|
1
4
|
export type QSParserConfig = {
|
|
5
|
+
/** Configuration options for parsing query strings */
|
|
2
6
|
parse: {
|
|
3
7
|
/**
|
|
4
8
|
* Nesting depth till the parameters should be parsed.
|
|
@@ -33,6 +37,7 @@ export type QSParserConfig = {
|
|
|
33
37
|
*/
|
|
34
38
|
comma: boolean;
|
|
35
39
|
};
|
|
40
|
+
/** Configuration options for stringifying query objects */
|
|
36
41
|
stringify: {
|
|
37
42
|
/**
|
|
38
43
|
* URI encode the stringified query string
|
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import { type Readable } from 'node:stream';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Configuration options for HTTP cookies that can be set on the response
|
|
4
4
|
*/
|
|
5
5
|
export type CookieOptions = {
|
|
6
|
+
/** Domain name for the cookie */
|
|
6
7
|
domain: string;
|
|
8
|
+
/** Expiration date for the cookie or function that returns the date */
|
|
7
9
|
expires: Date | (() => Date);
|
|
10
|
+
/** Whether the cookie should be accessible only through HTTP(S) */
|
|
8
11
|
httpOnly: boolean;
|
|
12
|
+
/** Maximum age of the cookie in seconds or as a string */
|
|
9
13
|
maxAge: number | string;
|
|
14
|
+
/** URL path for which the cookie is valid */
|
|
10
15
|
path: string;
|
|
16
|
+
/** SameSite attribute to control cross-site request behavior */
|
|
11
17
|
sameSite: boolean | 'lax' | 'none' | 'strict';
|
|
18
|
+
/** Whether the cookie should only be sent over HTTPS */
|
|
12
19
|
secure: boolean;
|
|
20
|
+
/** Whether the cookie should be partitioned (optional) */
|
|
13
21
|
partitioned?: boolean;
|
|
22
|
+
/** Priority level for the cookie (optional) */
|
|
14
23
|
priority?: 'low' | 'medium' | 'high';
|
|
15
24
|
};
|
|
16
25
|
/**
|
|
17
|
-
* Types
|
|
18
|
-
* string
|
|
26
|
+
* Types that can be cast to a string for HTTP response headers
|
|
19
27
|
*/
|
|
20
28
|
export type CastableHeader = string | number | boolean | string[] | number[] | boolean[];
|
|
21
29
|
/**
|
|
22
|
-
*
|
|
30
|
+
* Configuration options for HTTP response handling and processing
|
|
23
31
|
*/
|
|
24
32
|
export type ResponseConfig = {
|
|
25
33
|
/**
|
|
@@ -36,11 +44,11 @@ export type ResponseConfig = {
|
|
|
36
44
|
*/
|
|
37
45
|
jsonpCallbackName: string;
|
|
38
46
|
/**
|
|
39
|
-
*
|
|
47
|
+
* Default options to apply when setting cookies
|
|
40
48
|
*/
|
|
41
49
|
cookie: Partial<CookieOptions>;
|
|
42
50
|
};
|
|
43
51
|
/**
|
|
44
|
-
*
|
|
52
|
+
* A readable stream that can be piped to the response stream method
|
|
45
53
|
*/
|
|
46
54
|
export type ResponseStream = Readable;
|