@fluojs/http 1.0.0-beta.1 → 1.0.0-beta.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/README.ko.md +36 -5
- package/README.md +36 -5
- package/dist/adapter.d.ts +31 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +37 -0
- package/dist/adapters/binding.d.ts +6 -0
- package/dist/adapters/binding.d.ts.map +1 -1
- package/dist/adapters/binding.js +54 -55
- package/dist/adapters/dto-binding-plan.d.ts +22 -0
- package/dist/adapters/dto-binding-plan.d.ts.map +1 -0
- package/dist/adapters/dto-binding-plan.js +86 -0
- package/dist/adapters/dto-validation-adapter.d.ts +3 -1
- package/dist/adapters/dto-validation-adapter.d.ts.map +1 -1
- package/dist/adapters/dto-validation-adapter.js +10 -16
- package/dist/context/sse.d.ts +38 -0
- package/dist/context/sse.d.ts.map +1 -1
- package/dist/context/sse.js +50 -2
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +262 -53
- package/dist/dispatch/dispatch-content-negotiation.d.ts +17 -0
- package/dist/dispatch/dispatch-content-negotiation.d.ts.map +1 -1
- package/dist/dispatch/dispatch-content-negotiation.js +21 -0
- package/dist/dispatch/dispatch-error-policy.d.ts +8 -0
- package/dist/dispatch/dispatch-error-policy.d.ts.map +1 -1
- package/dist/dispatch/dispatch-error-policy.js +9 -0
- package/dist/dispatch/dispatch-handler-policy.d.ts +11 -1
- package/dist/dispatch/dispatch-handler-policy.d.ts.map +1 -1
- package/dist/dispatch/dispatch-handler-policy.js +17 -5
- package/dist/dispatch/dispatch-response-policy.d.ts +11 -1
- package/dist/dispatch/dispatch-response-policy.d.ts.map +1 -1
- package/dist/dispatch/dispatch-response-policy.js +44 -2
- package/dist/dispatch/dispatch-routing-policy.d.ts +13 -0
- package/dist/dispatch/dispatch-routing-policy.d.ts.map +1 -1
- package/dist/dispatch/dispatch-routing-policy.js +49 -4
- package/dist/dispatch/dispatcher.d.ts +24 -7
- package/dist/dispatch/dispatcher.d.ts.map +1 -1
- package/dist/dispatch/dispatcher.js +460 -48
- package/dist/dispatch/fast-path/debug-visibility.d.ts +18 -0
- package/dist/dispatch/fast-path/debug-visibility.d.ts.map +1 -0
- package/dist/dispatch/fast-path/debug-visibility.js +39 -0
- package/dist/dispatch/fast-path/eligibility-checker.d.ts +22 -0
- package/dist/dispatch/fast-path/eligibility-checker.d.ts.map +1 -0
- package/dist/dispatch/fast-path/eligibility-checker.js +107 -0
- package/dist/dispatch/fast-path/eligibility.d.ts +61 -0
- package/dist/dispatch/fast-path/eligibility.d.ts.map +1 -0
- package/dist/dispatch/fast-path/eligibility.js +23 -0
- package/dist/dispatch/fast-path/fast-path-executor.d.ts +21 -0
- package/dist/dispatch/fast-path/fast-path-executor.d.ts.map +1 -0
- package/dist/dispatch/fast-path/fast-path-executor.js +80 -0
- package/dist/dispatch/fast-path/index.d.ts +6 -0
- package/dist/dispatch/fast-path/index.d.ts.map +1 -0
- package/dist/dispatch/fast-path/index.js +4 -0
- package/dist/dispatch/native-route-handoff.d.ts +53 -0
- package/dist/dispatch/native-route-handoff.d.ts.map +1 -0
- package/dist/dispatch/native-route-handoff.js +97 -0
- package/dist/errors.d.ts +3 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +4 -0
- package/dist/guards.d.ts +7 -0
- package/dist/guards.d.ts.map +1 -1
- package/dist/guards.js +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/input-error-detail.d.ts +9 -0
- package/dist/input-error-detail.d.ts.map +1 -1
- package/dist/input-error-detail.js +10 -0
- package/dist/interceptors.d.ts +8 -0
- package/dist/interceptors.d.ts.map +1 -1
- package/dist/interceptors.js +14 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -1
- package/dist/mapping.d.ts +7 -0
- package/dist/mapping.d.ts.map +1 -1
- package/dist/mapping.js +93 -11
- package/dist/middleware/correlation.d.ts +5 -0
- package/dist/middleware/correlation.d.ts.map +1 -1
- package/dist/middleware/correlation.js +6 -0
- package/dist/middleware/cors.d.ts +9 -0
- package/dist/middleware/cors.d.ts.map +1 -1
- package/dist/middleware/cors.js +11 -0
- package/dist/middleware/middleware.d.ts +34 -0
- package/dist/middleware/middleware.d.ts.map +1 -1
- package/dist/middleware/middleware.js +47 -0
- package/dist/middleware/security-headers.d.ts +9 -0
- package/dist/middleware/security-headers.d.ts.map +1 -1
- package/dist/middleware/security-headers.js +11 -0
- package/dist/route-path.d.ts +41 -0
- package/dist/route-path.d.ts.map +1 -1
- package/dist/route-path.js +50 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-error-policy.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatch-error-policy.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAiBrD,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQvH"}
|
|
1
|
+
{"version":3,"file":"dispatch-error-policy.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatch-error-policy.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAiBrD;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQvH"}
|
|
@@ -14,6 +14,15 @@ function toHttpException(error) {
|
|
|
14
14
|
cause: error
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Write error response.
|
|
20
|
+
*
|
|
21
|
+
* @param error The error.
|
|
22
|
+
* @param response The response.
|
|
23
|
+
* @param requestId The request id.
|
|
24
|
+
* @returns The write error response result.
|
|
25
|
+
*/
|
|
17
26
|
export async function writeErrorResponse(error, response, requestId) {
|
|
18
27
|
if (response.committed) {
|
|
19
28
|
return;
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import type { RequestScopeContainer } from '@fluojs/di';
|
|
1
2
|
import type { Binder, HandlerDescriptor, RequestContext } from '../types.js';
|
|
2
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Invoke controller handler.
|
|
5
|
+
*
|
|
6
|
+
* @param handler The handler.
|
|
7
|
+
* @param requestContext The request context.
|
|
8
|
+
* @param binder The binder.
|
|
9
|
+
* @param controllerContainer Container used for resolving the controller instance before handler invocation.
|
|
10
|
+
* @returns The invoke controller handler result.
|
|
11
|
+
*/
|
|
12
|
+
export declare function invokeControllerHandler(handler: HandlerDescriptor, requestContext: RequestContext, binder?: Binder, controllerContainer?: RequestScopeContainer): Promise<unknown>;
|
|
3
13
|
//# sourceMappingURL=dispatch-handler-policy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-handler-policy.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatch-handler-policy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dispatch-handler-policy.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatch-handler-policy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAKxD,OAAO,KAAK,EAA2B,MAAM,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKtG;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,iBAAiB,EAC1B,cAAc,EAAE,cAAc,EAC9B,MAAM,GAAE,MAAsB,EAC9B,mBAAmB,GAAE,qBAAgD,GACpE,OAAO,CAAC,OAAO,CAAC,CAwBlB"}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { InvariantError } from '@fluojs/core';
|
|
2
2
|
import { DefaultBinder } from '../adapters/binding.js';
|
|
3
|
+
import { getCompiledDtoBindingPlan } from '../adapters/dto-binding-plan.js';
|
|
3
4
|
import { HttpDtoValidationAdapter } from '../adapters/dto-validation-adapter.js';
|
|
4
5
|
const defaultBinder = new DefaultBinder();
|
|
5
6
|
const defaultValidator = new HttpDtoValidationAdapter();
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Invoke controller handler.
|
|
10
|
+
*
|
|
11
|
+
* @param handler The handler.
|
|
12
|
+
* @param requestContext The request context.
|
|
13
|
+
* @param binder The binder.
|
|
14
|
+
* @param controllerContainer Container used for resolving the controller instance before handler invocation.
|
|
15
|
+
* @returns The invoke controller handler result.
|
|
16
|
+
*/
|
|
17
|
+
export async function invokeControllerHandler(handler, requestContext, binder = defaultBinder, controllerContainer = requestContext.container) {
|
|
18
|
+
const controller = await controllerContainer.resolve(handler.controllerToken);
|
|
8
19
|
const method = controller[handler.methodName];
|
|
9
20
|
if (typeof method !== 'function') {
|
|
10
21
|
throw new InvariantError(`Controller ${handler.controllerToken.name} does not expose handler method ${handler.methodName}.`);
|
|
@@ -13,9 +24,10 @@ export async function invokeControllerHandler(handler, requestContext, binder =
|
|
|
13
24
|
handler,
|
|
14
25
|
requestContext
|
|
15
26
|
};
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
const requestDto = handler.route.request;
|
|
28
|
+
const input = requestDto ? await binder.bind(requestDto, argumentResolverContext) : undefined;
|
|
29
|
+
if (requestDto && getCompiledDtoBindingPlan(requestDto).needsValidation) {
|
|
30
|
+
await defaultValidator.validate(input, requestDto);
|
|
19
31
|
}
|
|
20
32
|
return method.call(controller, input, requestContext);
|
|
21
33
|
}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { resolveContentNegotiation, type ResolvedContentNegotiation } from './dispatch-content-negotiation.js';
|
|
2
2
|
import { writeErrorResponse } from './dispatch-error-policy.js';
|
|
3
3
|
import type { FrameworkRequest, FrameworkResponse, HandlerDescriptor } from '../types.js';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Write success response.
|
|
6
|
+
*
|
|
7
|
+
* @param handler The handler.
|
|
8
|
+
* @param request The request.
|
|
9
|
+
* @param response The response.
|
|
10
|
+
* @param value The value.
|
|
11
|
+
* @param contentNegotiation The content negotiation.
|
|
12
|
+
* @returns The write success response result.
|
|
13
|
+
*/
|
|
14
|
+
export declare function writeSuccessResponse(handler: HandlerDescriptor, request: FrameworkRequest, response: FrameworkResponse, value: unknown, contentNegotiation: ResolvedContentNegotiation | undefined): ReturnType<FrameworkResponse['send']> | void;
|
|
5
15
|
export { resolveContentNegotiation, writeErrorResponse };
|
|
6
16
|
export type { ResolvedContentNegotiation };
|
|
7
17
|
//# sourceMappingURL=dispatch-response-policy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-response-policy.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatch-response-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EAEzB,KAAK,0BAA0B,EAChC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"dispatch-response-policy.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatch-response-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EAEzB,KAAK,0BAA0B,EAChC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,aAAa,CAAC;AAgErB;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,EAAE,OAAO,EACd,kBAAkB,EAAE,0BAA0B,GAAG,SAAS,GACzD,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAwC9C;AAED,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,CAAC;AACzD,YAAY,EAAE,0BAA0B,EAAE,CAAC"}
|
|
@@ -11,7 +11,46 @@ function resolveDefaultSuccessStatus(handler, value) {
|
|
|
11
11
|
return 200;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
function canUseSimpleJsonFastPath(response, value) {
|
|
15
|
+
return isSimpleJsonResponseBody(value) && !isResponseBodyForbidden(response.statusCode) && hasJsonCompatibleContentType(response);
|
|
16
|
+
}
|
|
17
|
+
function hasSimpleJsonResponseWriter(response) {
|
|
18
|
+
return typeof response.sendSimpleJson === 'function';
|
|
19
|
+
}
|
|
20
|
+
function isSimpleJsonResponseBody(value) {
|
|
21
|
+
if (Array.isArray(value)) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return typeof value === 'object' && value !== null && Object.getPrototypeOf(value) === Object.prototype;
|
|
25
|
+
}
|
|
26
|
+
function isResponseBodyForbidden(status) {
|
|
27
|
+
return status === 204 || status === 205 || status === 304;
|
|
28
|
+
}
|
|
29
|
+
function hasJsonCompatibleContentType(response) {
|
|
30
|
+
const contentType = readHeader(response.headers, 'content-type');
|
|
31
|
+
return contentType === undefined || isJsonContentType(contentType);
|
|
32
|
+
}
|
|
33
|
+
function readHeader(headers, name) {
|
|
34
|
+
const lowerName = name.toLowerCase();
|
|
35
|
+
const entry = Object.entries(headers).find(([headerName]) => headerName.toLowerCase() === lowerName);
|
|
36
|
+
const value = entry?.[1];
|
|
37
|
+
return typeof value === 'string' ? value : undefined;
|
|
38
|
+
}
|
|
39
|
+
function isJsonContentType(contentType) {
|
|
40
|
+
return contentType.toLowerCase().includes('application/json') || contentType.toLowerCase().endsWith('+json');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Write success response.
|
|
45
|
+
*
|
|
46
|
+
* @param handler The handler.
|
|
47
|
+
* @param request The request.
|
|
48
|
+
* @param response The response.
|
|
49
|
+
* @param value The value.
|
|
50
|
+
* @param contentNegotiation The content negotiation.
|
|
51
|
+
* @returns The write success response result.
|
|
52
|
+
*/
|
|
53
|
+
export function writeSuccessResponse(handler, request, response, value, contentNegotiation) {
|
|
15
54
|
if (response.committed) {
|
|
16
55
|
return;
|
|
17
56
|
}
|
|
@@ -39,7 +78,10 @@ export async function writeSuccessResponse(handler, request, response, value, co
|
|
|
39
78
|
} else if (response.statusSet !== true) {
|
|
40
79
|
response.setStatus(resolveDefaultSuccessStatus(handler, value));
|
|
41
80
|
}
|
|
81
|
+
if (!formatter && hasSimpleJsonResponseWriter(response) && canUseSimpleJsonFastPath(response, value)) {
|
|
82
|
+
return response.sendSimpleJson(value);
|
|
83
|
+
}
|
|
42
84
|
const responseBody = formatter ? formatter.format(value) : value;
|
|
43
|
-
|
|
85
|
+
return response.send(responseBody);
|
|
44
86
|
}
|
|
45
87
|
export { resolveContentNegotiation, writeErrorResponse };
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { FrameworkRequest, HandlerMapping, HandlerMatch, RequestContext } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Match handler or throw.
|
|
4
|
+
*
|
|
5
|
+
* @param handlerMapping The handler mapping.
|
|
6
|
+
* @param request The request.
|
|
7
|
+
* @returns The match handler or throw result.
|
|
8
|
+
*/
|
|
2
9
|
export declare function matchHandlerOrThrow(handlerMapping: HandlerMapping, request: FrameworkRequest): HandlerMatch;
|
|
10
|
+
/**
|
|
11
|
+
* Update request params.
|
|
12
|
+
*
|
|
13
|
+
* @param requestContext The request context.
|
|
14
|
+
* @param params The params.
|
|
15
|
+
*/
|
|
3
16
|
export declare function updateRequestParams(requestContext: RequestContext, params: Readonly<Record<string, string>>): void;
|
|
4
17
|
//# sourceMappingURL=dispatch-routing-policy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-routing-policy.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatch-routing-policy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElG,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,GAAG,YAAY,CAQ3G;
|
|
1
|
+
{"version":3,"file":"dispatch-routing-policy.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatch-routing-policy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElG;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,GAAG,YAAY,CAQ3G;AA2BD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAsBlH"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { HandlerNotFoundError } from '../errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Match handler or throw.
|
|
4
|
+
*
|
|
5
|
+
* @param handlerMapping The handler mapping.
|
|
6
|
+
* @param request The request.
|
|
7
|
+
* @returns The match handler or throw result.
|
|
8
|
+
*/
|
|
2
9
|
export function matchHandlerOrThrow(handlerMapping, request) {
|
|
3
10
|
const match = handlerMapping.match(request);
|
|
4
11
|
if (!match) {
|
|
@@ -6,9 +13,47 @@ export function matchHandlerOrThrow(handlerMapping, request) {
|
|
|
6
13
|
}
|
|
7
14
|
return match;
|
|
8
15
|
}
|
|
16
|
+
function defineRequestParams(request, params) {
|
|
17
|
+
Object.defineProperty(request, 'params', {
|
|
18
|
+
configurable: true,
|
|
19
|
+
enumerable: true,
|
|
20
|
+
value: params,
|
|
21
|
+
writable: true
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function findInheritedParamsDescriptor(request) {
|
|
25
|
+
let prototype = Object.getPrototypeOf(request);
|
|
26
|
+
while (prototype) {
|
|
27
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, 'params');
|
|
28
|
+
if (descriptor) {
|
|
29
|
+
return descriptor;
|
|
30
|
+
}
|
|
31
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Update request params.
|
|
38
|
+
*
|
|
39
|
+
* @param requestContext The request context.
|
|
40
|
+
* @param params The params.
|
|
41
|
+
*/
|
|
9
42
|
export function updateRequestParams(requestContext, params) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
43
|
+
const request = requestContext.request;
|
|
44
|
+
const ownDescriptor = Object.getOwnPropertyDescriptor(request, 'params');
|
|
45
|
+
if (ownDescriptor) {
|
|
46
|
+
if ('value' in ownDescriptor && ownDescriptor.writable) {
|
|
47
|
+
request.params = params;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
defineRequestParams(request, params);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const inheritedDescriptor = findInheritedParamsDescriptor(request);
|
|
54
|
+
if (!inheritedDescriptor || 'value' in inheritedDescriptor && inheritedDescriptor.writable) {
|
|
55
|
+
request.params = params;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
defineRequestParams(request, params);
|
|
14
59
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { Container } from '@fluojs/di';
|
|
2
|
-
import type { Binder, ContentNegotiationOptions, Dispatcher, DispatcherLogger, FrameworkRequest, FrameworkResponse, HandlerMapping, InterceptorLike, MiddlewareLike, RequestObserverLike } from '../types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import type { Binder, ContentNegotiationOptions, ConverterLike, Dispatcher, DispatcherLogger, FrameworkRequest, FrameworkResponse, HandlerMapping, InterceptorLike, MiddlewareLike, RequestObserverLike } from '../types.js';
|
|
3
|
+
import { type FastPathStats } from './fast-path/index.js';
|
|
4
|
+
export type { FastPathEligibility, FastPathStats } from './fast-path/index.js';
|
|
5
|
+
export { FAST_PATH_ELIGIBILITY_SYMBOL, FAST_PATH_STATS_SYMBOL } from './fast-path/index.js';
|
|
6
|
+
/** Type definition for a global HTTP error handler function. */
|
|
6
7
|
export type ErrorHandler = (error: unknown, request: FrameworkRequest, response: FrameworkResponse, requestId?: string) => Promise<boolean | void> | boolean | void;
|
|
7
|
-
/**
|
|
8
|
-
* Options for creating an HTTP {@link Dispatcher}.
|
|
9
|
-
*/
|
|
8
|
+
/** Options for creating an HTTP {@link Dispatcher}. */
|
|
10
9
|
export interface CreateDispatcherOptions {
|
|
11
10
|
/** Global middleware applied to all requests. */
|
|
12
11
|
appMiddleware?: MiddlewareLike[];
|
|
@@ -20,11 +19,21 @@ export interface CreateDispatcherOptions {
|
|
|
20
19
|
interceptors?: InterceptorLike[];
|
|
21
20
|
/** Global request observers for telemetry and logging. */
|
|
22
21
|
observers?: RequestObserverLike[];
|
|
22
|
+
/** Emits per-response fast-path debug headers when enabled. */
|
|
23
|
+
fastPathDebugHeaders?: boolean;
|
|
23
24
|
/** Optional global error handler. */
|
|
24
25
|
onError?: ErrorHandler;
|
|
26
|
+
/** Request-scope optimization hints supplied by runtime bootstrap. */
|
|
27
|
+
requestScope?: {
|
|
28
|
+
/** Global DTO converters used by the default binder. */
|
|
29
|
+
converterDefinitions?: readonly ConverterLike[];
|
|
30
|
+
};
|
|
31
|
+
/** Logger used for non-fatal dispatcher failures. */
|
|
25
32
|
logger?: DispatcherLogger;
|
|
26
33
|
/** Root DI container for creating request scopes. */
|
|
27
34
|
rootContainer: Container;
|
|
35
|
+
/** Human-readable adapter label included in fast-path observability output. */
|
|
36
|
+
adapter?: string;
|
|
28
37
|
}
|
|
29
38
|
/**
|
|
30
39
|
* Creates an HTTP dispatcher instance for processing requests.
|
|
@@ -33,4 +42,12 @@ export interface CreateDispatcherOptions {
|
|
|
33
42
|
* @returns A {@link Dispatcher} capable of routing {@link FrameworkRequest}s.
|
|
34
43
|
*/
|
|
35
44
|
export declare function createDispatcher(options: CreateDispatcherOptions): Dispatcher;
|
|
45
|
+
/**
|
|
46
|
+
* Reads automatic fast-path eligibility statistics attached to a dispatcher.
|
|
47
|
+
*
|
|
48
|
+
* @param dispatcher Dispatcher returned by {@link createDispatcher}.
|
|
49
|
+
* @returns Fast-path statistics when available.
|
|
50
|
+
*/
|
|
51
|
+
export declare function getDispatcherFastPathStats(dispatcher: Dispatcher): FastPathStats | undefined;
|
|
52
|
+
export { formatFastPathStats } from './fast-path/index.js';
|
|
36
53
|
//# sourceMappingURL=dispatcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAyB,MAAM,YAAY,CAAC;AAQnE,OAAO,KAAK,EACV,MAAM,EACN,yBAAyB,EACzB,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAIjB,cAAc,EAEd,eAAe,EAEf,cAAc,EAId,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAKrB,OAAO,EAKL,KAAK,aAAa,EAOnB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE5F,gEAAgE;AAChE,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,OAAO,GAAG,IAAI,CAAC;AAEpK,uDAAuD;AACvD,MAAM,WAAW,uBAAuB;IACtC,iDAAiD;IACjD,aAAa,CAAC,EAAE,cAAc,EAAE,CAAC;IACjC,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;IAC/C,sDAAsD;IACtD,cAAc,EAAE,cAAc,CAAC;IAC/B,2DAA2D;IAC3D,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;IACjC,0DAA0D;IAC1D,SAAS,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAClC,+DAA+D;IAC/D,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qCAAqC;IACrC,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,sEAAsE;IACtE,YAAY,CAAC,EAAE;QACb,wDAAwD;QACxD,oBAAoB,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;KACjD,CAAC;IACF,qDAAqD;IACrD,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,qDAAqD;IACrD,aAAa,EAAE,SAAS,CAAC;IACzB,+EAA+E;IAC/E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAoyBD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,UAAU,CAuF7E;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,UAAU,GAAG,aAAa,GAAG,SAAS,CAE5F;AAED,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC"}
|