@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.
- package/LICENSE +21 -0
- package/README.ko.md +142 -0
- package/README.md +144 -0
- package/dist/adapter.d.ts +58 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +42 -0
- package/dist/adapters/binding.d.ts +11 -0
- package/dist/adapters/binding.d.ts.map +1 -0
- package/dist/adapters/binding.js +185 -0
- package/dist/adapters/dto-validation-adapter.d.ts +10 -0
- package/dist/adapters/dto-validation-adapter.d.ts.map +1 -0
- package/dist/adapters/dto-validation-adapter.js +46 -0
- package/dist/client-identity.d.ts +21 -0
- package/dist/client-identity.d.ts.map +1 -0
- package/dist/client-identity.js +108 -0
- package/dist/context/request-context.d.ts +53 -0
- package/dist/context/request-context.d.ts.map +1 -0
- package/dist/context/request-context.js +89 -0
- package/dist/context/sse.d.ts +21 -0
- package/dist/context/sse.d.ts.map +1 -0
- package/dist/context/sse.js +106 -0
- package/dist/decorators.d.ts +188 -0
- package/dist/decorators.d.ts.map +1 -0
- package/dist/decorators.js +378 -0
- package/dist/dispatch/dispatch-content-negotiation.d.ts +9 -0
- package/dist/dispatch/dispatch-content-negotiation.d.ts.map +1 -0
- package/dist/dispatch/dispatch-content-negotiation.js +164 -0
- package/dist/dispatch/dispatch-error-policy.d.ts +3 -0
- package/dist/dispatch/dispatch-error-policy.d.ts.map +1 -0
- package/dist/dispatch/dispatch-error-policy.js +24 -0
- package/dist/dispatch/dispatch-handler-policy.d.ts +3 -0
- package/dist/dispatch/dispatch-handler-policy.d.ts.map +1 -0
- package/dist/dispatch/dispatch-handler-policy.js +21 -0
- package/dist/dispatch/dispatch-response-policy.d.ts +7 -0
- package/dist/dispatch/dispatch-response-policy.d.ts.map +1 -0
- package/dist/dispatch/dispatch-response-policy.js +45 -0
- package/dist/dispatch/dispatch-routing-policy.d.ts +4 -0
- package/dist/dispatch/dispatch-routing-policy.d.ts.map +1 -0
- package/dist/dispatch/dispatch-routing-policy.js +14 -0
- package/dist/dispatch/dispatcher.d.ts +36 -0
- package/dist/dispatch/dispatcher.d.ts.map +1 -0
- package/dist/dispatch/dispatcher.js +196 -0
- package/dist/errors.d.ts +23 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +41 -0
- package/dist/exceptions.d.ts +174 -0
- package/dist/exceptions.d.ts.map +1 -0
- package/dist/exceptions.js +222 -0
- package/dist/guards.d.ts +3 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +19 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/input-error-detail.d.ts +10 -0
- package/dist/input-error-detail.d.ts.map +1 -0
- package/dist/input-error-detail.js +8 -0
- package/dist/interceptors.d.ts +3 -0
- package/dist/interceptors.d.ts.map +1 -0
- package/dist/interceptors.js +22 -0
- package/dist/internal.d.ts +3 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +2 -0
- package/dist/mapping.d.ts +7 -0
- package/dist/mapping.d.ts.map +1 -0
- package/dist/mapping.js +244 -0
- package/dist/middleware/correlation.d.ts +3 -0
- package/dist/middleware/correlation.d.ts.map +1 -0
- package/dist/middleware/correlation.js +19 -0
- package/dist/middleware/cors.d.ts +11 -0
- package/dist/middleware/cors.d.ts.map +1 -0
- package/dist/middleware/cors.js +57 -0
- package/dist/middleware/middleware.d.ts +8 -0
- package/dist/middleware/middleware.d.ts.map +1 -0
- package/dist/middleware/middleware.js +64 -0
- package/dist/middleware/rate-limit.d.ts +39 -0
- package/dist/middleware/rate-limit.d.ts.map +1 -0
- package/dist/middleware/rate-limit.js +106 -0
- package/dist/middleware/security-headers.d.ts +12 -0
- package/dist/middleware/security-headers.d.ts.map +1 -0
- package/dist/middleware/security-headers.js +47 -0
- package/dist/route-path.d.ts +15 -0
- package/dist/route-path.d.ts.map +1 -0
- package/dist/route-path.js +69 -0
- package/dist/types.d.ts +274 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +114 -0
- package/package.json +58 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import type { Constructor, MaybePromise, MetadataPropertyKey, MetadataSource, Token } from '@fluojs/core';
|
|
2
|
+
import type { RequestScopeContainer } from '@fluojs/di';
|
|
3
|
+
export type { ValidationIssue, Validator } from '@fluojs/validation';
|
|
4
|
+
/** HTTP methods understood by Fluo route metadata and dispatcher matching. */
|
|
5
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'ALL';
|
|
6
|
+
/** Strategies that decide how versioned HTTP routes are selected for one request. */
|
|
7
|
+
export declare enum VersioningType {
|
|
8
|
+
URI = "URI",
|
|
9
|
+
HEADER = "HEADER",
|
|
10
|
+
MEDIA_TYPE = "MEDIA_TYPE",
|
|
11
|
+
CUSTOM = "CUSTOM"
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Adapter-normalized incoming request passed through the HTTP pipeline.
|
|
15
|
+
*
|
|
16
|
+
* Runtime adapters populate this shape so decorators, binders, guards, and
|
|
17
|
+
* middleware can reason about one stable contract instead of platform-specific
|
|
18
|
+
* request objects.
|
|
19
|
+
*/
|
|
20
|
+
export interface FrameworkRequest {
|
|
21
|
+
method: HttpMethod | string;
|
|
22
|
+
path: string;
|
|
23
|
+
url: string;
|
|
24
|
+
headers: Readonly<Record<string, string | string[] | undefined>>;
|
|
25
|
+
query: Readonly<Record<string, string | string[] | undefined>>;
|
|
26
|
+
cookies: Readonly<Record<string, string | undefined>>;
|
|
27
|
+
params: Readonly<Record<string, string>>;
|
|
28
|
+
body?: unknown;
|
|
29
|
+
rawBody?: Uint8Array;
|
|
30
|
+
raw: unknown;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Adapter-normalized mutable response facade shared across dispatch stages.
|
|
35
|
+
*
|
|
36
|
+
* Dispatch policies write headers, status, redirects, and bodies through this
|
|
37
|
+
* contract before the underlying platform commits the response.
|
|
38
|
+
*/
|
|
39
|
+
export interface FrameworkResponse {
|
|
40
|
+
compression?: FrameworkResponseCompression;
|
|
41
|
+
statusCode?: number;
|
|
42
|
+
statusSet?: boolean;
|
|
43
|
+
headers: Record<string, string | string[]>;
|
|
44
|
+
committed: boolean;
|
|
45
|
+
raw?: unknown;
|
|
46
|
+
stream?: FrameworkResponseStream;
|
|
47
|
+
setStatus(code: number): void;
|
|
48
|
+
setHeader(name: string, value: string | string[]): void;
|
|
49
|
+
redirect(status: number, location: string): void;
|
|
50
|
+
send(body: unknown): MaybePromise<void>;
|
|
51
|
+
}
|
|
52
|
+
/** Compression writer used when a platform can stream encoded response bodies. */
|
|
53
|
+
export interface FrameworkResponseCompression {
|
|
54
|
+
write(body: Uint8Array, options?: FrameworkResponseCompressionWriteOptions): MaybePromise<boolean>;
|
|
55
|
+
}
|
|
56
|
+
/** Additional metadata passed to a response compression writer. */
|
|
57
|
+
export interface FrameworkResponseCompressionWriteOptions {
|
|
58
|
+
contentType?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Low-level streaming handle used by SSE and other incremental response flows.
|
|
62
|
+
*/
|
|
63
|
+
export interface FrameworkResponseStream {
|
|
64
|
+
readonly closed: boolean;
|
|
65
|
+
close(): void;
|
|
66
|
+
flush?(): void;
|
|
67
|
+
onClose?(listener: () => void): (() => void) | void;
|
|
68
|
+
waitForDrain?(): Promise<void>;
|
|
69
|
+
write(chunk: string | Uint8Array): boolean;
|
|
70
|
+
}
|
|
71
|
+
/** Serializer used during response content negotiation. */
|
|
72
|
+
export interface ResponseFormatter {
|
|
73
|
+
readonly mediaType: string;
|
|
74
|
+
format(body: unknown): string | Buffer;
|
|
75
|
+
}
|
|
76
|
+
/** Response negotiation settings applied to one route or dispatcher instance. */
|
|
77
|
+
export interface ContentNegotiationOptions {
|
|
78
|
+
defaultMediaType?: string;
|
|
79
|
+
formatters?: ResponseFormatter[];
|
|
80
|
+
}
|
|
81
|
+
/** Authenticated caller identity attached to the active request context. */
|
|
82
|
+
export interface Principal {
|
|
83
|
+
subject: string;
|
|
84
|
+
issuer?: string;
|
|
85
|
+
audience?: string | string[];
|
|
86
|
+
roles?: string[];
|
|
87
|
+
scopes?: string[];
|
|
88
|
+
claims: Record<string, unknown>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Per-request execution context shared across binding, guards, interceptors,
|
|
92
|
+
* and controller handlers.
|
|
93
|
+
*/
|
|
94
|
+
export interface RequestContext {
|
|
95
|
+
request: FrameworkRequest;
|
|
96
|
+
response: FrameworkResponse;
|
|
97
|
+
requestId?: string;
|
|
98
|
+
principal?: Principal;
|
|
99
|
+
metadata: Record<string | symbol, unknown>;
|
|
100
|
+
container: RequestScopeContainer;
|
|
101
|
+
}
|
|
102
|
+
/** Typed metadata key used to store request-scoped values safely. */
|
|
103
|
+
export interface ContextKey<T> {
|
|
104
|
+
readonly id: symbol;
|
|
105
|
+
readonly description: string;
|
|
106
|
+
readonly __type?: T;
|
|
107
|
+
}
|
|
108
|
+
/** Controller method signature after DTO binding and request-context injection. */
|
|
109
|
+
export type ControllerHandler<Input = unknown, Result = unknown> = (input: Input, ctx: RequestContext) => MaybePromise<Result>;
|
|
110
|
+
/**
|
|
111
|
+
* Route-level behavioral metadata collected from HTTP decorators.
|
|
112
|
+
*/
|
|
113
|
+
export interface RouteDefinition {
|
|
114
|
+
method: HttpMethod;
|
|
115
|
+
path: string;
|
|
116
|
+
produces?: string[];
|
|
117
|
+
request?: Constructor;
|
|
118
|
+
guards?: GuardLike[];
|
|
119
|
+
headers?: {
|
|
120
|
+
name: string;
|
|
121
|
+
value: string;
|
|
122
|
+
}[];
|
|
123
|
+
interceptors?: InterceptorLike[];
|
|
124
|
+
redirect?: {
|
|
125
|
+
url: string;
|
|
126
|
+
statusCode?: number;
|
|
127
|
+
};
|
|
128
|
+
successStatus?: number;
|
|
129
|
+
version?: string;
|
|
130
|
+
}
|
|
131
|
+
/** Derived metadata used while mapping controllers into dispatchable handlers. */
|
|
132
|
+
export interface HandlerMetadata {
|
|
133
|
+
controllerPath: string;
|
|
134
|
+
effectivePath: string;
|
|
135
|
+
effectiveVersion?: string;
|
|
136
|
+
moduleMiddleware: MiddlewareLike[];
|
|
137
|
+
moduleType?: Constructor;
|
|
138
|
+
pathParams: string[];
|
|
139
|
+
}
|
|
140
|
+
/** Fully resolved controller handler descriptor stored in handler mappings. */
|
|
141
|
+
export interface HandlerDescriptor {
|
|
142
|
+
controllerToken: Constructor;
|
|
143
|
+
metadata: HandlerMetadata;
|
|
144
|
+
methodName: string;
|
|
145
|
+
route: RouteDefinition;
|
|
146
|
+
}
|
|
147
|
+
/** Result returned when request matching resolves one handler and path params. */
|
|
148
|
+
export interface HandlerMatch {
|
|
149
|
+
descriptor: HandlerDescriptor;
|
|
150
|
+
params: Readonly<Record<string, string>>;
|
|
151
|
+
}
|
|
152
|
+
/** Immutable lookup table that matches incoming requests to controller handlers. */
|
|
153
|
+
export interface HandlerMapping {
|
|
154
|
+
readonly descriptors: HandlerDescriptor[];
|
|
155
|
+
match(request: FrameworkRequest): HandlerMatch | undefined;
|
|
156
|
+
}
|
|
157
|
+
/** Source module/controller pair used to build a handler mapping. */
|
|
158
|
+
export interface HandlerSource {
|
|
159
|
+
controllerToken: Constructor;
|
|
160
|
+
moduleMiddleware?: MiddlewareLike[];
|
|
161
|
+
moduleType?: Constructor;
|
|
162
|
+
}
|
|
163
|
+
/** Candidate version values returned by a custom version extractor. */
|
|
164
|
+
export type VersioningExtractorResult = string | readonly string[] | undefined;
|
|
165
|
+
/** Callback that extracts route version candidates from one framework request. */
|
|
166
|
+
export type VersioningExtractor = (request: FrameworkRequest) => VersioningExtractorResult;
|
|
167
|
+
/**
|
|
168
|
+
* Versioning configuration shared by dispatcher and route-mapping policies.
|
|
169
|
+
*/
|
|
170
|
+
export type VersioningOptions = {
|
|
171
|
+
type?: VersioningType.URI;
|
|
172
|
+
} | {
|
|
173
|
+
type: VersioningType.HEADER;
|
|
174
|
+
header: string;
|
|
175
|
+
} | {
|
|
176
|
+
type: VersioningType.MEDIA_TYPE;
|
|
177
|
+
key?: string;
|
|
178
|
+
} | {
|
|
179
|
+
type: VersioningType.CUSTOM;
|
|
180
|
+
extractor: VersioningExtractor;
|
|
181
|
+
};
|
|
182
|
+
/** Runtime dispatcher that executes the full HTTP request lifecycle. */
|
|
183
|
+
export interface Dispatcher {
|
|
184
|
+
dispatch(request: FrameworkRequest, response: FrameworkResponse): Promise<void>;
|
|
185
|
+
}
|
|
186
|
+
/** Logger seam used by the dispatcher for non-fatal internal failure reporting. */
|
|
187
|
+
export interface DispatcherLogger {
|
|
188
|
+
error(message: string, error?: unknown, context?: string): void;
|
|
189
|
+
}
|
|
190
|
+
/** Observation payload delivered to request observers throughout one dispatch. */
|
|
191
|
+
export interface RequestObservationContext {
|
|
192
|
+
handler?: HandlerDescriptor;
|
|
193
|
+
requestContext: RequestContext;
|
|
194
|
+
}
|
|
195
|
+
/** Continuation callback that advances middleware or interceptor execution. */
|
|
196
|
+
export type Next = () => Promise<void>;
|
|
197
|
+
/** Input passed to one middleware invocation. */
|
|
198
|
+
export interface MiddlewareContext {
|
|
199
|
+
request: FrameworkRequest;
|
|
200
|
+
requestContext: RequestContext;
|
|
201
|
+
response: FrameworkResponse;
|
|
202
|
+
}
|
|
203
|
+
/** Request pipeline middleware contract. */
|
|
204
|
+
export interface Middleware {
|
|
205
|
+
handle(context: MiddlewareContext, next: Next): MaybePromise<void>;
|
|
206
|
+
}
|
|
207
|
+
/** Declarative middleware binding for selected route patterns. */
|
|
208
|
+
export interface MiddlewareRouteConfig {
|
|
209
|
+
middleware: Constructor<Middleware>;
|
|
210
|
+
routes: string[];
|
|
211
|
+
}
|
|
212
|
+
/** Guard execution context for one matched handler invocation. */
|
|
213
|
+
export interface GuardContext {
|
|
214
|
+
handler: HandlerDescriptor;
|
|
215
|
+
requestContext: RequestContext;
|
|
216
|
+
}
|
|
217
|
+
/** Authorization or precondition contract evaluated before handler execution. */
|
|
218
|
+
export interface Guard {
|
|
219
|
+
canActivate(context: GuardContext): MaybePromise<void | boolean>;
|
|
220
|
+
}
|
|
221
|
+
/** Lazy handle that lets interceptors continue into the next execution stage. */
|
|
222
|
+
export interface CallHandler {
|
|
223
|
+
handle(): Promise<unknown>;
|
|
224
|
+
}
|
|
225
|
+
/** Interceptor execution context for one matched handler. */
|
|
226
|
+
export interface InterceptorContext {
|
|
227
|
+
handler: HandlerDescriptor;
|
|
228
|
+
requestContext: RequestContext;
|
|
229
|
+
}
|
|
230
|
+
/** Around-invocation hook for transforming handler input, output, or errors. */
|
|
231
|
+
export interface Interceptor {
|
|
232
|
+
intercept(context: InterceptorContext, next: CallHandler): MaybePromise<unknown>;
|
|
233
|
+
}
|
|
234
|
+
/** Lifecycle observer notified as one request moves through dispatch stages. */
|
|
235
|
+
export interface RequestObserver {
|
|
236
|
+
onHandlerMatched?(context: RequestObservationContext): MaybePromise<void>;
|
|
237
|
+
onRequestError?(context: RequestObservationContext, error: unknown): MaybePromise<void>;
|
|
238
|
+
onRequestFinish?(context: RequestObservationContext): MaybePromise<void>;
|
|
239
|
+
onRequestStart?(context: RequestObservationContext): MaybePromise<void>;
|
|
240
|
+
onRequestSuccess?(context: RequestObservationContext, value: unknown): MaybePromise<void>;
|
|
241
|
+
}
|
|
242
|
+
/** Context passed to DTO binders while resolving handler arguments. */
|
|
243
|
+
export interface ArgumentResolverContext {
|
|
244
|
+
handler: HandlerDescriptor;
|
|
245
|
+
requestContext: RequestContext;
|
|
246
|
+
}
|
|
247
|
+
/** Converter reference accepted by binding decorators and binder configuration. */
|
|
248
|
+
export type ConverterLike = Converter | Token<Converter>;
|
|
249
|
+
/** DTO property target metadata supplied to a converter invocation. */
|
|
250
|
+
export interface ConverterTarget {
|
|
251
|
+
dto: Constructor;
|
|
252
|
+
handler: HandlerDescriptor;
|
|
253
|
+
key: string;
|
|
254
|
+
propertyKey: MetadataPropertyKey;
|
|
255
|
+
requestContext: RequestContext;
|
|
256
|
+
source: MetadataSource;
|
|
257
|
+
}
|
|
258
|
+
/** DTO binder that materializes one handler input object from request data. */
|
|
259
|
+
export interface Binder {
|
|
260
|
+
bind(dto: Constructor, context: ArgumentResolverContext): MaybePromise<unknown>;
|
|
261
|
+
}
|
|
262
|
+
/** Value converter used to coerce one bound request field into a target shape. */
|
|
263
|
+
export interface Converter {
|
|
264
|
+
convert(value: unknown, target: ConverterTarget): MaybePromise<unknown>;
|
|
265
|
+
}
|
|
266
|
+
/** Middleware reference accepted by module/runtime configuration. */
|
|
267
|
+
export type MiddlewareLike = Middleware | Token<Middleware> | MiddlewareRouteConfig;
|
|
268
|
+
/** Guard reference accepted by route metadata and runtime configuration. */
|
|
269
|
+
export type GuardLike = Guard | Token<Guard>;
|
|
270
|
+
/** Interceptor reference accepted by route metadata and runtime configuration. */
|
|
271
|
+
export type InterceptorLike = Interceptor | Token<Interceptor>;
|
|
272
|
+
/** Request observer reference accepted by runtime configuration. */
|
|
273
|
+
export type RequestObserverLike = RequestObserver | Token<RequestObserver>;
|
|
274
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1G,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAErE,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,CAAC;AAElG,qFA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AAc,EAAE,cAAc,CAAC;CAChC;AAED,mFAAmF;AACnF,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;AAEzD,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,WAAW,CAAC;IACjB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,mBAAmB,CAAC;IACjC,cAAc,EAAE,cAAc,CAAC;IAC/B,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,+EAA+E;AAC/E,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,uBAAuB,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CACjF;AAED,kFAAkF;AAClF,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CACzE;AAED,qEAAqE;AACrE,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,qBAAqB,CAAC;AACpF,4EAA4E;AAC5E,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;AAC7C,kFAAkF;AAClF,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;AAC/D,oEAAoE;AACpE,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/** HTTP methods understood by Fluo route metadata and dispatcher matching. */
|
|
2
|
+
|
|
3
|
+
/** Strategies that decide how versioned HTTP routes are selected for one request. */
|
|
4
|
+
export let VersioningType = /*#__PURE__*/function (VersioningType) {
|
|
5
|
+
VersioningType["URI"] = "URI";
|
|
6
|
+
VersioningType["HEADER"] = "HEADER";
|
|
7
|
+
VersioningType["MEDIA_TYPE"] = "MEDIA_TYPE";
|
|
8
|
+
VersioningType["CUSTOM"] = "CUSTOM";
|
|
9
|
+
return VersioningType;
|
|
10
|
+
}({});
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Adapter-normalized incoming request passed through the HTTP pipeline.
|
|
14
|
+
*
|
|
15
|
+
* Runtime adapters populate this shape so decorators, binders, guards, and
|
|
16
|
+
* middleware can reason about one stable contract instead of platform-specific
|
|
17
|
+
* request objects.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Adapter-normalized mutable response facade shared across dispatch stages.
|
|
22
|
+
*
|
|
23
|
+
* Dispatch policies write headers, status, redirects, and bodies through this
|
|
24
|
+
* contract before the underlying platform commits the response.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** Compression writer used when a platform can stream encoded response bodies. */
|
|
28
|
+
|
|
29
|
+
/** Additional metadata passed to a response compression writer. */
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Low-level streaming handle used by SSE and other incremental response flows.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/** Serializer used during response content negotiation. */
|
|
36
|
+
|
|
37
|
+
/** Response negotiation settings applied to one route or dispatcher instance. */
|
|
38
|
+
|
|
39
|
+
/** Authenticated caller identity attached to the active request context. */
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Per-request execution context shared across binding, guards, interceptors,
|
|
43
|
+
* and controller handlers.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/** Typed metadata key used to store request-scoped values safely. */
|
|
47
|
+
|
|
48
|
+
/** Controller method signature after DTO binding and request-context injection. */
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Route-level behavioral metadata collected from HTTP decorators.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/** Derived metadata used while mapping controllers into dispatchable handlers. */
|
|
55
|
+
|
|
56
|
+
/** Fully resolved controller handler descriptor stored in handler mappings. */
|
|
57
|
+
|
|
58
|
+
/** Result returned when request matching resolves one handler and path params. */
|
|
59
|
+
|
|
60
|
+
/** Immutable lookup table that matches incoming requests to controller handlers. */
|
|
61
|
+
|
|
62
|
+
/** Source module/controller pair used to build a handler mapping. */
|
|
63
|
+
|
|
64
|
+
/** Candidate version values returned by a custom version extractor. */
|
|
65
|
+
|
|
66
|
+
/** Callback that extracts route version candidates from one framework request. */
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Versioning configuration shared by dispatcher and route-mapping policies.
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
/** Runtime dispatcher that executes the full HTTP request lifecycle. */
|
|
73
|
+
|
|
74
|
+
/** Logger seam used by the dispatcher for non-fatal internal failure reporting. */
|
|
75
|
+
|
|
76
|
+
/** Observation payload delivered to request observers throughout one dispatch. */
|
|
77
|
+
|
|
78
|
+
/** Continuation callback that advances middleware or interceptor execution. */
|
|
79
|
+
|
|
80
|
+
/** Input passed to one middleware invocation. */
|
|
81
|
+
|
|
82
|
+
/** Request pipeline middleware contract. */
|
|
83
|
+
|
|
84
|
+
/** Declarative middleware binding for selected route patterns. */
|
|
85
|
+
|
|
86
|
+
/** Guard execution context for one matched handler invocation. */
|
|
87
|
+
|
|
88
|
+
/** Authorization or precondition contract evaluated before handler execution. */
|
|
89
|
+
|
|
90
|
+
/** Lazy handle that lets interceptors continue into the next execution stage. */
|
|
91
|
+
|
|
92
|
+
/** Interceptor execution context for one matched handler. */
|
|
93
|
+
|
|
94
|
+
/** Around-invocation hook for transforming handler input, output, or errors. */
|
|
95
|
+
|
|
96
|
+
/** Lifecycle observer notified as one request moves through dispatch stages. */
|
|
97
|
+
|
|
98
|
+
/** Context passed to DTO binders while resolving handler arguments. */
|
|
99
|
+
|
|
100
|
+
/** Converter reference accepted by binding decorators and binder configuration. */
|
|
101
|
+
|
|
102
|
+
/** DTO property target metadata supplied to a converter invocation. */
|
|
103
|
+
|
|
104
|
+
/** DTO binder that materializes one handler input object from request data. */
|
|
105
|
+
|
|
106
|
+
/** Value converter used to coerce one bound request field into a target shape. */
|
|
107
|
+
|
|
108
|
+
/** Middleware reference accepted by module/runtime configuration. */
|
|
109
|
+
|
|
110
|
+
/** Guard reference accepted by route metadata and runtime configuration. */
|
|
111
|
+
|
|
112
|
+
/** Interceptor reference accepted by route metadata and runtime configuration. */
|
|
113
|
+
|
|
114
|
+
/** Request observer reference accepted by runtime configuration. */
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluojs/http",
|
|
3
|
+
"description": "HTTP execution layer — routing, guards, interceptors, DTO binding, and exception handling for Fluo.",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"fluo",
|
|
6
|
+
"http",
|
|
7
|
+
"routing",
|
|
8
|
+
"guards",
|
|
9
|
+
"interceptors",
|
|
10
|
+
"controller",
|
|
11
|
+
"rest"
|
|
12
|
+
],
|
|
13
|
+
"version": "1.0.0-beta.1",
|
|
14
|
+
"private": false,
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/fluojs/fluo.git",
|
|
19
|
+
"directory": "packages/http"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=20.0.0"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"type": "module",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./internal": {
|
|
34
|
+
"types": "./dist/internal.d.ts",
|
|
35
|
+
"import": "./dist/internal.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"main": "./dist/index.js",
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"files": [
|
|
41
|
+
"dist"
|
|
42
|
+
],
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@fluojs/validation": "^1.0.0-beta.1",
|
|
45
|
+
"@fluojs/core": "^1.0.0-beta.1",
|
|
46
|
+
"@fluojs/di": "^1.0.0-beta.1"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"vitest": "^3.2.4"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"prebuild": "node ../../tooling/scripts/clean-dist.mjs",
|
|
53
|
+
"build": "pnpm exec babel src --extensions .ts --ignore 'src/**/*.test.ts' --out-dir dist --config-file ../../tooling/babel/babel.config.cjs && pnpm exec tsc -p tsconfig.build.json",
|
|
54
|
+
"typecheck": "pnpm exec tsc -p tsconfig.json --noEmit",
|
|
55
|
+
"test": "pnpm exec vitest run -c vitest.config.ts",
|
|
56
|
+
"test:watch": "pnpm exec vitest -c vitest.config.ts"
|
|
57
|
+
}
|
|
58
|
+
}
|