@fluojs/http 1.0.0-beta.1

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 (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.ko.md +142 -0
  3. package/README.md +144 -0
  4. package/dist/adapter.d.ts +58 -0
  5. package/dist/adapter.d.ts.map +1 -0
  6. package/dist/adapter.js +42 -0
  7. package/dist/adapters/binding.d.ts +11 -0
  8. package/dist/adapters/binding.d.ts.map +1 -0
  9. package/dist/adapters/binding.js +185 -0
  10. package/dist/adapters/dto-validation-adapter.d.ts +10 -0
  11. package/dist/adapters/dto-validation-adapter.d.ts.map +1 -0
  12. package/dist/adapters/dto-validation-adapter.js +46 -0
  13. package/dist/client-identity.d.ts +21 -0
  14. package/dist/client-identity.d.ts.map +1 -0
  15. package/dist/client-identity.js +108 -0
  16. package/dist/context/request-context.d.ts +53 -0
  17. package/dist/context/request-context.d.ts.map +1 -0
  18. package/dist/context/request-context.js +89 -0
  19. package/dist/context/sse.d.ts +21 -0
  20. package/dist/context/sse.d.ts.map +1 -0
  21. package/dist/context/sse.js +106 -0
  22. package/dist/decorators.d.ts +188 -0
  23. package/dist/decorators.d.ts.map +1 -0
  24. package/dist/decorators.js +378 -0
  25. package/dist/dispatch/dispatch-content-negotiation.d.ts +9 -0
  26. package/dist/dispatch/dispatch-content-negotiation.d.ts.map +1 -0
  27. package/dist/dispatch/dispatch-content-negotiation.js +164 -0
  28. package/dist/dispatch/dispatch-error-policy.d.ts +3 -0
  29. package/dist/dispatch/dispatch-error-policy.d.ts.map +1 -0
  30. package/dist/dispatch/dispatch-error-policy.js +24 -0
  31. package/dist/dispatch/dispatch-handler-policy.d.ts +3 -0
  32. package/dist/dispatch/dispatch-handler-policy.d.ts.map +1 -0
  33. package/dist/dispatch/dispatch-handler-policy.js +21 -0
  34. package/dist/dispatch/dispatch-response-policy.d.ts +7 -0
  35. package/dist/dispatch/dispatch-response-policy.d.ts.map +1 -0
  36. package/dist/dispatch/dispatch-response-policy.js +45 -0
  37. package/dist/dispatch/dispatch-routing-policy.d.ts +4 -0
  38. package/dist/dispatch/dispatch-routing-policy.d.ts.map +1 -0
  39. package/dist/dispatch/dispatch-routing-policy.js +14 -0
  40. package/dist/dispatch/dispatcher.d.ts +36 -0
  41. package/dist/dispatch/dispatcher.d.ts.map +1 -0
  42. package/dist/dispatch/dispatcher.js +196 -0
  43. package/dist/errors.d.ts +23 -0
  44. package/dist/errors.d.ts.map +1 -0
  45. package/dist/errors.js +41 -0
  46. package/dist/exceptions.d.ts +174 -0
  47. package/dist/exceptions.d.ts.map +1 -0
  48. package/dist/exceptions.js +222 -0
  49. package/dist/guards.d.ts +3 -0
  50. package/dist/guards.d.ts.map +1 -0
  51. package/dist/guards.js +19 -0
  52. package/dist/index.d.ts +15 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/dist/index.js +14 -0
  55. package/dist/input-error-detail.d.ts +10 -0
  56. package/dist/input-error-detail.d.ts.map +1 -0
  57. package/dist/input-error-detail.js +8 -0
  58. package/dist/interceptors.d.ts +3 -0
  59. package/dist/interceptors.d.ts.map +1 -0
  60. package/dist/interceptors.js +22 -0
  61. package/dist/internal.d.ts +3 -0
  62. package/dist/internal.d.ts.map +1 -0
  63. package/dist/internal.js +2 -0
  64. package/dist/mapping.d.ts +7 -0
  65. package/dist/mapping.d.ts.map +1 -0
  66. package/dist/mapping.js +244 -0
  67. package/dist/middleware/correlation.d.ts +3 -0
  68. package/dist/middleware/correlation.d.ts.map +1 -0
  69. package/dist/middleware/correlation.js +19 -0
  70. package/dist/middleware/cors.d.ts +11 -0
  71. package/dist/middleware/cors.d.ts.map +1 -0
  72. package/dist/middleware/cors.js +57 -0
  73. package/dist/middleware/middleware.d.ts +8 -0
  74. package/dist/middleware/middleware.d.ts.map +1 -0
  75. package/dist/middleware/middleware.js +64 -0
  76. package/dist/middleware/rate-limit.d.ts +39 -0
  77. package/dist/middleware/rate-limit.d.ts.map +1 -0
  78. package/dist/middleware/rate-limit.js +106 -0
  79. package/dist/middleware/security-headers.d.ts +12 -0
  80. package/dist/middleware/security-headers.d.ts.map +1 -0
  81. package/dist/middleware/security-headers.js +47 -0
  82. package/dist/route-path.d.ts +15 -0
  83. package/dist/route-path.d.ts.map +1 -0
  84. package/dist/route-path.js +69 -0
  85. package/dist/types.d.ts +274 -0
  86. package/dist/types.d.ts.map +1 -0
  87. package/dist/types.js +114 -0
  88. package/package.json +58 -0
@@ -0,0 +1,14 @@
1
+ import { HandlerNotFoundError } from '../errors.js';
2
+ export function matchHandlerOrThrow(handlerMapping, request) {
3
+ const match = handlerMapping.match(request);
4
+ if (!match) {
5
+ throw new HandlerNotFoundError(`No handler registered for ${request.method} ${request.path}.`);
6
+ }
7
+ return match;
8
+ }
9
+ export function updateRequestParams(requestContext, params) {
10
+ requestContext.request = {
11
+ ...requestContext.request,
12
+ params
13
+ };
14
+ }
@@ -0,0 +1,36 @@
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
+ * Type definition for a global HTTP error handler function.
5
+ */
6
+ 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
+ */
10
+ export interface CreateDispatcherOptions {
11
+ /** Global middleware applied to all requests. */
12
+ appMiddleware?: MiddlewareLike[];
13
+ /** Optional parameter binder for mapping request data to controller arguments. */
14
+ binder?: Binder;
15
+ /** Optional content negotiation configuration. */
16
+ contentNegotiation?: ContentNegotiationOptions;
17
+ /** Mapping of routes to their respective handlers. */
18
+ handlerMapping: HandlerMapping;
19
+ /** Global interceptors applied to all matched handlers. */
20
+ interceptors?: InterceptorLike[];
21
+ /** Global request observers for telemetry and logging. */
22
+ observers?: RequestObserverLike[];
23
+ /** Optional global error handler. */
24
+ onError?: ErrorHandler;
25
+ logger?: DispatcherLogger;
26
+ /** Root DI container for creating request scopes. */
27
+ rootContainer: Container;
28
+ }
29
+ /**
30
+ * Creates an HTTP dispatcher instance for processing requests.
31
+ *
32
+ * @param options Configuration for routing, middleware, and dependency resolution.
33
+ * @returns A {@link Dispatcher} capable of routing {@link FrameworkRequest}s.
34
+ */
35
+ export declare function createDispatcher(options: CreateDispatcherOptions): Dispatcher;
36
+ //# sourceMappingURL=dispatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/dispatch/dispatcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAW5C,OAAO,KAAK,EACV,MAAM,EACN,yBAAyB,EACzB,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAGjB,cAAc,EACd,eAAe,EAGf,cAAc,EAId,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,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;;GAEG;AACH,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,qCAAqC;IACrC,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,qDAAqD;IACrD,aAAa,EAAE,SAAS,CAAC;CAC1B;AAmQD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,UAAU,CA8B7E"}
@@ -0,0 +1,196 @@
1
+ import { invokeControllerHandler } from './dispatch-handler-policy.js';
2
+ import { resolveContentNegotiation, writeErrorResponse, writeSuccessResponse } from './dispatch-response-policy.js';
3
+ import { matchHandlerOrThrow, updateRequestParams } from './dispatch-routing-policy.js';
4
+ import { RequestAbortedError } from '../errors.js';
5
+ import { runGuardChain } from '../guards.js';
6
+ import { runInterceptorChain } from '../interceptors.js';
7
+ import { runMiddlewareChain } from '../middleware/middleware.js';
8
+ import { createRequestContext, runWithRequestContext } from '../context/request-context.js';
9
+ import { SseResponse } from '../context/sse.js';
10
+
11
+ /**
12
+ * Type definition for a global HTTP error handler function.
13
+ */
14
+
15
+ /**
16
+ * Options for creating an HTTP {@link Dispatcher}.
17
+ */
18
+
19
+ function logDispatchFailure(logger, message, error) {
20
+ if (logger) {
21
+ logger.error(message, error, 'HttpDispatcher');
22
+ return;
23
+ }
24
+ console.error(`[fluo][HttpDispatcher] ${message}`, error);
25
+ }
26
+ function createDispatchRequest(request) {
27
+ return {
28
+ ...request,
29
+ params: {
30
+ ...request.params
31
+ }
32
+ };
33
+ }
34
+ function readRequestId(request) {
35
+ const raw = request.headers['x-request-id'] ?? request.headers['X-Request-Id'];
36
+ const value = Array.isArray(raw) ? raw[0] : raw;
37
+ const normalized = value?.trim();
38
+ return normalized ? normalized : undefined;
39
+ }
40
+ function createDispatchContext(request, response, rootContainer) {
41
+ return createRequestContext({
42
+ container: rootContainer.createRequestScope(),
43
+ metadata: {},
44
+ request,
45
+ requestId: readRequestId(request),
46
+ response
47
+ });
48
+ }
49
+ function ensureRequestNotAborted(request) {
50
+ if (request.signal?.aborted) {
51
+ throw new RequestAbortedError();
52
+ }
53
+ }
54
+ function isRequestObserver(value) {
55
+ return typeof value === 'object' && value !== null;
56
+ }
57
+ async function resolveRequestObserver(definition, requestContext) {
58
+ if (isRequestObserver(definition)) {
59
+ return definition;
60
+ }
61
+ return requestContext.container.resolve(definition);
62
+ }
63
+ async function notifyObservers(observers, requestContext, callback, handler) {
64
+ const context = {
65
+ handler,
66
+ requestContext
67
+ };
68
+ for (const definition of observers) {
69
+ const observer = await resolveRequestObserver(definition, requestContext);
70
+ await callback(observer, context);
71
+ }
72
+ }
73
+ async function notifyObserversSafely(observers, requestContext, callback, logger, handler) {
74
+ try {
75
+ await notifyObservers(observers, requestContext, callback, handler);
76
+ } catch (error) {
77
+ logDispatchFailure(logger, 'Request observer threw an unhandled error.', error);
78
+ }
79
+ }
80
+ async function dispatchMatchedHandler(handler, requestContext, observers, contentNegotiation, binder, globalInterceptors, logger) {
81
+ const guardContext = {
82
+ handler,
83
+ requestContext
84
+ };
85
+ const interceptorContext = {
86
+ handler,
87
+ requestContext
88
+ };
89
+ await runGuardChain(handler.route.guards ?? [], guardContext);
90
+ if (requestContext.response.committed) {
91
+ return;
92
+ }
93
+ const interceptors = [...(globalInterceptors ?? []), ...(handler.route.interceptors ?? [])];
94
+ const result = await runInterceptorChain(interceptors, interceptorContext, async () => {
95
+ return invokeControllerHandler(handler, requestContext, binder);
96
+ });
97
+ ensureRequestNotAborted(requestContext.request);
98
+ if (!(result instanceof SseResponse) && !requestContext.response.committed) {
99
+ await writeSuccessResponse(handler, requestContext.request, requestContext.response, result, contentNegotiation);
100
+ }
101
+ await notifyObserversSafely(observers, requestContext, async (observer, context) => {
102
+ await observer.onRequestSuccess?.(context, result);
103
+ }, logger, handler);
104
+ }
105
+ async function notifyRequestStart(context) {
106
+ await notifyObserversSafely(context.observers, context.requestContext, async (observer, observationContext) => {
107
+ await observer.onRequestStart?.(observationContext);
108
+ }, context.options.logger);
109
+ }
110
+ async function notifyHandlerMatched(context, descriptor) {
111
+ await notifyObserversSafely(context.observers, context.requestContext, async (observer, observationContext) => {
112
+ await observer.onHandlerMatched?.(observationContext);
113
+ }, context.options.logger, descriptor);
114
+ }
115
+ async function notifyRequestError(context, error) {
116
+ await notifyObserversSafely(context.observers, context.requestContext, async (observer, observationContext) => {
117
+ await observer.onRequestError?.(observationContext, error);
118
+ }, context.options.logger, context.matchedHandler);
119
+ }
120
+ async function notifyRequestFinish(context) {
121
+ await notifyObserversSafely(context.observers, context.requestContext, async (observer, observationContext) => {
122
+ await observer.onRequestFinish?.(observationContext);
123
+ }, context.options.logger, context.matchedHandler);
124
+ }
125
+ async function runDispatchPipeline(context) {
126
+ ensureRequestNotAborted(context.requestContext.request);
127
+ const appMiddlewareContext = {
128
+ request: context.requestContext.request,
129
+ requestContext: context.requestContext,
130
+ response: context.response
131
+ };
132
+ await runMiddlewareChain(context.options.appMiddleware ?? [], appMiddlewareContext, async () => {
133
+ if (context.response.committed) {
134
+ return;
135
+ }
136
+ const match = matchHandlerOrThrow(context.options.handlerMapping, appMiddlewareContext.request);
137
+ context.matchedHandler = match.descriptor;
138
+ updateRequestParams(context.requestContext, match.params);
139
+ await notifyHandlerMatched(context, match.descriptor);
140
+ const moduleMiddlewareContext = {
141
+ request: context.requestContext.request,
142
+ requestContext: context.requestContext,
143
+ response: context.response
144
+ };
145
+ await runMiddlewareChain(match.descriptor.metadata.moduleMiddleware ?? [], moduleMiddlewareContext, async () => {
146
+ await dispatchMatchedHandler(match.descriptor, context.requestContext, context.observers, context.contentNegotiation, context.options.binder, context.options.interceptors, context.options.logger);
147
+ });
148
+ });
149
+ }
150
+ async function handleDispatchError(context, error) {
151
+ if (error instanceof RequestAbortedError || context.requestContext.request.signal?.aborted) {
152
+ return;
153
+ }
154
+ await notifyRequestError(context, error);
155
+ const handled = await context.options.onError?.(error, context.requestContext.request, context.response, context.requestContext.requestId);
156
+ if (handled) {
157
+ return;
158
+ }
159
+ await writeErrorResponse(error, context.response, context.requestContext.requestId);
160
+ }
161
+
162
+ /**
163
+ * Creates an HTTP dispatcher instance for processing requests.
164
+ *
165
+ * @param options Configuration for routing, middleware, and dependency resolution.
166
+ * @returns A {@link Dispatcher} capable of routing {@link FrameworkRequest}s.
167
+ */
168
+ export function createDispatcher(options) {
169
+ const contentNegotiation = resolveContentNegotiation(options.contentNegotiation);
170
+ return {
171
+ async dispatch(request, response) {
172
+ const phaseContext = {
173
+ contentNegotiation,
174
+ observers: options.observers ?? [],
175
+ options,
176
+ requestContext: createDispatchContext(createDispatchRequest(request), response, options.rootContainer),
177
+ response
178
+ };
179
+ await runWithRequestContext(phaseContext.requestContext, async () => {
180
+ try {
181
+ await notifyRequestStart(phaseContext);
182
+ await runDispatchPipeline(phaseContext);
183
+ } catch (error) {
184
+ await handleDispatchError(phaseContext, error);
185
+ } finally {
186
+ await notifyRequestFinish(phaseContext);
187
+ try {
188
+ await phaseContext.requestContext.container.dispose();
189
+ } catch (error) {
190
+ logDispatchFailure(options.logger, 'Request-scoped container dispose threw an error.', error);
191
+ }
192
+ }
193
+ });
194
+ }
195
+ };
196
+ }
@@ -0,0 +1,23 @@
1
+ import { FluoError } from '@fluojs/core';
2
+ /**
3
+ * Error thrown when two or more routes share the same path and method pattern.
4
+ */
5
+ export declare class RouteConflictError extends FluoError {
6
+ constructor(message: string);
7
+ }
8
+ export declare class InvalidRoutePathError extends FluoError {
9
+ constructor(message: string);
10
+ }
11
+ /**
12
+ * Error thrown when no handler matches the incoming request path or method.
13
+ */
14
+ export declare class HandlerNotFoundError extends FluoError {
15
+ constructor(message: string);
16
+ }
17
+ /**
18
+ * Error thrown when a request is aborted by the client before processing completes.
19
+ */
20
+ export declare class RequestAbortedError extends FluoError {
21
+ constructor(message?: string);
22
+ }
23
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,qBAAsB,SAAQ,SAAS;gBACtC,OAAO,EAAE,MAAM;CAG5B;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;gBACrC,OAAO,EAAE,MAAM;CAG5B;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;gBACpC,OAAO,SAA4C;CAGhE"}
package/dist/errors.js ADDED
@@ -0,0 +1,41 @@
1
+ import { FluoError } from '@fluojs/core';
2
+
3
+ /**
4
+ * Error thrown when two or more routes share the same path and method pattern.
5
+ */
6
+ export class RouteConflictError extends FluoError {
7
+ constructor(message) {
8
+ super(message, {
9
+ code: 'ROUTE_CONFLICT'
10
+ });
11
+ }
12
+ }
13
+ export class InvalidRoutePathError extends FluoError {
14
+ constructor(message) {
15
+ super(message, {
16
+ code: 'INVALID_ROUTE_PATH'
17
+ });
18
+ }
19
+ }
20
+
21
+ /**
22
+ * Error thrown when no handler matches the incoming request path or method.
23
+ */
24
+ export class HandlerNotFoundError extends FluoError {
25
+ constructor(message) {
26
+ super(message, {
27
+ code: 'HANDLER_NOT_FOUND'
28
+ });
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Error thrown when a request is aborted by the client before processing completes.
34
+ */
35
+ export class RequestAbortedError extends FluoError {
36
+ constructor(message = 'Request aborted before response commit.') {
37
+ super(message, {
38
+ code: 'REQUEST_ABORTED'
39
+ });
40
+ }
41
+ }
@@ -0,0 +1,174 @@
1
+ import { FluoError, type MetadataSource } from '@fluojs/core';
2
+ /**
3
+ * Detailed error information for field-level validation or binding failures.
4
+ */
5
+ export interface HttpExceptionDetail {
6
+ /** Stable error code for this specific detail. */
7
+ code: string;
8
+ /** Name of the field that failed validation. */
9
+ field?: string;
10
+ /** Human-readable error message. */
11
+ message: string;
12
+ /** Source of the metadata that triggered the failure. */
13
+ source?: MetadataSource;
14
+ }
15
+ /**
16
+ * Optional metadata used when creating an {@link HttpException}.
17
+ */
18
+ export interface HttpExceptionOptions {
19
+ /** Original error or value that triggered this HTTP exception. */
20
+ cause?: unknown;
21
+ /** Stable application-level error code serialized into API responses. */
22
+ code?: string;
23
+ /** Field-level or source-level details for validation and binding failures. */
24
+ details?: HttpExceptionDetail[];
25
+ /** Additional structured metadata serialized for observability and client diagnostics. */
26
+ meta?: Record<string, unknown>;
27
+ }
28
+ /**
29
+ * Canonical HTTP error response envelope.
30
+ */
31
+ export interface ErrorResponse {
32
+ error: {
33
+ code: string;
34
+ details?: HttpExceptionDetail[];
35
+ message: string;
36
+ meta?: Record<string, unknown>;
37
+ requestId?: string;
38
+ status: number;
39
+ };
40
+ }
41
+ /**
42
+ * Base HTTP exception type used by the dispatcher error serializer.
43
+ */
44
+ export declare class HttpException extends FluoError {
45
+ /** Detailed field-level or source-level error info. */
46
+ readonly details?: HttpExceptionDetail[];
47
+ /** HTTP status code. */
48
+ readonly status: number;
49
+ /**
50
+ * Creates an HTTP exception with status, message, and optional structured error metadata.
51
+ *
52
+ * @param status HTTP status code used by the dispatcher when writing the error response.
53
+ * @param message Human-readable error message exposed in the serialized envelope.
54
+ * @param options Optional structured metadata including `code`, `details`, `meta`, and `cause`.
55
+ */
56
+ constructor(status: number, message: string, options?: HttpExceptionOptions);
57
+ }
58
+ /**
59
+ * HTTP 400 Bad Request exception.
60
+ */
61
+ export declare class BadRequestException extends HttpException {
62
+ /**
63
+ * Creates a 400 Bad Request exception.
64
+ *
65
+ * @param message Human-readable reason for rejecting the request.
66
+ * @param options Optional structured details and metadata serialized in the error envelope.
67
+ */
68
+ constructor(message?: string, options?: Omit<HttpExceptionOptions, 'code'>);
69
+ }
70
+ /**
71
+ * HTTP 401 Unauthorized exception.
72
+ */
73
+ export declare class UnauthorizedException extends HttpException {
74
+ /**
75
+ * Creates a 401 Unauthorized exception.
76
+ *
77
+ * @param message Human-readable authentication failure reason.
78
+ * @param options Optional structured details and metadata serialized in the error envelope.
79
+ */
80
+ constructor(message?: string, options?: Omit<HttpExceptionOptions, 'code'>);
81
+ }
82
+ /**
83
+ * HTTP 403 Forbidden exception.
84
+ */
85
+ export declare class ForbiddenException extends HttpException {
86
+ /**
87
+ * Creates a 403 Forbidden exception.
88
+ *
89
+ * @param message Human-readable authorization failure reason.
90
+ * @param options Optional structured details and metadata serialized in the error envelope.
91
+ */
92
+ constructor(message?: string, options?: Omit<HttpExceptionOptions, 'code'>);
93
+ }
94
+ /**
95
+ * HTTP 404 Not Found exception.
96
+ */
97
+ export declare class NotFoundException extends HttpException {
98
+ /**
99
+ * Creates a 404 Not Found exception.
100
+ *
101
+ * @param message Human-readable missing-resource reason.
102
+ * @param options Optional structured details and metadata serialized in the error envelope.
103
+ */
104
+ constructor(message?: string, options?: Omit<HttpExceptionOptions, 'code'>);
105
+ }
106
+ /**
107
+ * HTTP 409 Conflict exception.
108
+ */
109
+ export declare class ConflictException extends HttpException {
110
+ /**
111
+ * Creates a 409 Conflict exception.
112
+ *
113
+ * @param message Human-readable conflict reason.
114
+ * @param options Optional structured details and metadata serialized in the error envelope.
115
+ */
116
+ constructor(message?: string, options?: Omit<HttpExceptionOptions, 'code'>);
117
+ }
118
+ /**
119
+ * HTTP 406 Not Acceptable exception.
120
+ */
121
+ export declare class NotAcceptableException extends HttpException {
122
+ /**
123
+ * Creates a 406 Not Acceptable exception.
124
+ *
125
+ * @param message Human-readable content-negotiation failure reason.
126
+ * @param options Optional structured details and metadata serialized in the error envelope.
127
+ */
128
+ constructor(message?: string, options?: Omit<HttpExceptionOptions, 'code'>);
129
+ }
130
+ /**
131
+ * HTTP 429 Too Many Requests exception.
132
+ */
133
+ export declare class TooManyRequestsException extends HttpException {
134
+ /**
135
+ * Creates a 429 Too Many Requests exception.
136
+ *
137
+ * @param message Human-readable throttling reason.
138
+ * @param options Optional structured details and metadata serialized in the error envelope.
139
+ */
140
+ constructor(message?: string, options?: Omit<HttpExceptionOptions, 'code'>);
141
+ }
142
+ /**
143
+ * HTTP 413 Payload Too Large exception.
144
+ */
145
+ export declare class PayloadTooLargeException extends HttpException {
146
+ /**
147
+ * Creates a 413 Payload Too Large exception.
148
+ *
149
+ * @param message Human-readable payload-size failure reason.
150
+ * @param options Optional structured details and metadata serialized in the error envelope.
151
+ */
152
+ constructor(message?: string, options?: Omit<HttpExceptionOptions, 'code'>);
153
+ }
154
+ /**
155
+ * HTTP 500 Internal Server Error exception.
156
+ */
157
+ export declare class InternalServerErrorException extends HttpException {
158
+ /**
159
+ * Creates a 500 Internal Server Error exception.
160
+ *
161
+ * @param message Human-readable server-side failure reason.
162
+ * @param options Optional structured details and metadata serialized in the error envelope.
163
+ */
164
+ constructor(message?: string, options?: Omit<HttpExceptionOptions, 'code'>);
165
+ }
166
+ /**
167
+ * Converts an {@link HttpException} to the standard serialized error envelope.
168
+ *
169
+ * @param error HTTP exception produced by application code or the dispatcher pipeline.
170
+ * @param requestId Optional request identifier attached by runtime correlation middleware.
171
+ * @returns The canonical `{ error: ... }` payload returned to HTTP clients.
172
+ */
173
+ export declare function createErrorResponse(error: HttpException, requestId?: string): ErrorResponse;
174
+ //# sourceMappingURL=exceptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,kEAAkE;IAClE,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,yE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