@stacksjs/bun-router 0.0.17 → 0.0.19

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 (153) hide show
  1. package/dist/chunk-2mx7fq49.js +4 -0
  2. package/dist/chunk-a8p83068.js +103 -0
  3. package/dist/{chunk-cgptvjdf.js → chunk-y3xq6wq6.js} +1 -1
  4. package/dist/cli.js +4 -3
  5. package/dist/container/index.js +1149 -211
  6. package/dist/container/service-provider.d.ts +3 -3
  7. package/dist/development/performance-profiler.d.ts +3 -3
  8. package/dist/development/route-debugger.d.ts +1 -1
  9. package/dist/development/route-inspector.d.ts +2 -2
  10. package/dist/index.js +369 -2209
  11. package/dist/observability/integration.d.ts +1 -1
  12. package/dist/response/macros.d.ts +1 -1
  13. package/dist/router/index.d.ts +7 -7
  14. package/dist/router/router.d.ts +0 -32
  15. package/dist/testing/performance-testing.d.ts +2 -2
  16. package/dist/testing/test-client.d.ts +1 -1
  17. package/dist/testing/websocket-testing.d.ts +1 -1
  18. package/package.json +7 -7
  19. package/dist/chunk-1ahs68ys.js +0 -18
  20. package/dist/chunk-g3ybefhg.js +0 -1923
  21. package/src/auth.ts +0 -489
  22. package/src/cache/lru-cache.ts +0 -457
  23. package/src/cache/middleware-memoization.ts +0 -531
  24. package/src/cache/route-cache-warmer.ts +0 -486
  25. package/src/cache/sqlite-cache.ts +0 -783
  26. package/src/cache/streaming-cache.ts +0 -572
  27. package/src/cli/colors.ts +0 -29
  28. package/src/cli/index.ts +0 -287
  29. package/src/cli/middleware.ts +0 -291
  30. package/src/cli/openapi.ts +0 -407
  31. package/src/cli/router.ts +0 -188
  32. package/src/cli/routes.ts +0 -265
  33. package/src/cli/utils.ts +0 -531
  34. package/src/cli.ts +0 -5
  35. package/src/config.ts +0 -322
  36. package/src/container/container.ts +0 -786
  37. package/src/container/contextual-binding.ts +0 -606
  38. package/src/container/decorators.ts +0 -368
  39. package/src/container/index.ts +0 -49
  40. package/src/container/service-provider.ts +0 -596
  41. package/src/development/hot-reload.ts +0 -673
  42. package/src/development/index.ts +0 -499
  43. package/src/development/performance-profiler.ts +0 -717
  44. package/src/development/route-debugger.ts +0 -527
  45. package/src/development/route-inspector.ts +0 -749
  46. package/src/development/typescript-utilities.ts +0 -682
  47. package/src/docs.ts +0 -397
  48. package/src/errors/circuit-breaker.ts +0 -733
  49. package/src/errors/error-handler.ts +0 -569
  50. package/src/errors/error-reporting.ts +0 -672
  51. package/src/errors/exceptions.ts +0 -536
  52. package/src/errors/graceful-degradation.ts +0 -623
  53. package/src/errors/index.ts +0 -21
  54. package/src/errors/router-errors.ts +0 -632
  55. package/src/file-serving/static-files.ts +0 -718
  56. package/src/index.ts +0 -66
  57. package/src/middleware/auth.ts +0 -220
  58. package/src/middleware/content_security_policy.ts +0 -215
  59. package/src/middleware/cors.ts +0 -142
  60. package/src/middleware/csrf.ts +0 -166
  61. package/src/middleware/ddos_protection.ts +0 -279
  62. package/src/middleware/file_security.ts +0 -191
  63. package/src/middleware/file_upload.ts +0 -275
  64. package/src/middleware/helmet.ts +0 -268
  65. package/src/middleware/index.ts +0 -117
  66. package/src/middleware/input_validation.ts +0 -453
  67. package/src/middleware/json_body.ts +0 -37
  68. package/src/middleware/performance_alerting.ts +0 -540
  69. package/src/middleware/performance_dashboard.ts +0 -661
  70. package/src/middleware/performance_monitor.ts +0 -945
  71. package/src/middleware/pipeline.ts +0 -489
  72. package/src/middleware/rate_limit.ts +0 -251
  73. package/src/middleware/request_id.ts +0 -36
  74. package/src/middleware/request_signing.ts +0 -638
  75. package/src/middleware/request_tracer.ts +0 -653
  76. package/src/middleware/response_cache.ts +0 -778
  77. package/src/middleware/security.ts +0 -482
  78. package/src/middleware/security_suite.ts +0 -257
  79. package/src/middleware/session.ts +0 -91
  80. package/src/model-binding/index.ts +0 -18
  81. package/src/model-binding/model-middleware.ts +0 -425
  82. package/src/model-binding/model-registry.ts +0 -550
  83. package/src/model-binding.ts +0 -370
  84. package/src/model-resolver-factory.ts +0 -106
  85. package/src/observability/correlation.ts +0 -691
  86. package/src/observability/health-checks.ts +0 -729
  87. package/src/observability/index.ts +0 -184
  88. package/src/observability/integration.ts +0 -548
  89. package/src/observability/metrics.ts +0 -753
  90. package/src/observability/tracing.ts +0 -638
  91. package/src/optimization/bun-utilities.ts +0 -778
  92. package/src/query-builder-integration.ts +0 -137
  93. package/src/request/context.ts +0 -109
  94. package/src/request/enhanced-request.ts +0 -876
  95. package/src/request/macros.ts +0 -822
  96. package/src/response/macros.ts +0 -665
  97. package/src/response/response-factory.ts +0 -596
  98. package/src/router/api-routes.ts +0 -243
  99. package/src/router/file-based-routing.ts +0 -697
  100. package/src/router/file-streaming.ts +0 -383
  101. package/src/router/fluent-routing.ts +0 -866
  102. package/src/router/group-organization.ts +0 -229
  103. package/src/router/handler-resolver.ts +0 -327
  104. package/src/router/http-methods.ts +0 -407
  105. package/src/router/index.ts +0 -193
  106. package/src/router/middleware-groups.ts +0 -222
  107. package/src/router/middleware-integration.ts +0 -399
  108. package/src/router/middleware.ts +0 -234
  109. package/src/router/model-binding.ts +0 -215
  110. package/src/router/optimized-route-matching.ts +0 -302
  111. package/src/router/route-building.ts +0 -221
  112. package/src/router/route-compiler.ts +0 -691
  113. package/src/router/route-matching.ts +0 -368
  114. package/src/router/route-trie.ts +0 -450
  115. package/src/router/router.ts +0 -1616
  116. package/src/router/server.ts +0 -684
  117. package/src/router/validation-integration.ts +0 -449
  118. package/src/router/view-rendering.ts +0 -233
  119. package/src/router/websocket.ts +0 -100
  120. package/src/routing/route-caching.ts +0 -402
  121. package/src/routing/route-throttling.ts +0 -469
  122. package/src/routing/subdomain-routing.ts +0 -492
  123. package/src/session/database-store.ts +0 -109
  124. package/src/session/file-store.ts +0 -148
  125. package/src/session/index.ts +0 -244
  126. package/src/session/memory-store.ts +0 -88
  127. package/src/session/redis-store.ts +0 -93
  128. package/src/streaming/index.ts +0 -17
  129. package/src/streaming/sse-handler.ts +0 -482
  130. package/src/streaming/stream-handler.ts +0 -552
  131. package/src/testing/auth-testing.ts +0 -448
  132. package/src/testing/file-upload-testing.ts +0 -543
  133. package/src/testing/index.ts +0 -10
  134. package/src/testing/middleware-testing.ts +0 -322
  135. package/src/testing/model-binding-testing.ts +0 -645
  136. package/src/testing/performance-testing.ts +0 -738
  137. package/src/testing/test-client.ts +0 -310
  138. package/src/testing/test-request.ts +0 -315
  139. package/src/testing/test-response.ts +0 -332
  140. package/src/testing/types.ts +0 -224
  141. package/src/testing/websocket-testing.ts +0 -590
  142. package/src/types/controller-types.ts +0 -385
  143. package/src/types/core.ts +0 -683
  144. package/src/types/middleware-types.ts +0 -422
  145. package/src/types/request-response-augmentation.ts +0 -489
  146. package/src/types/route-inference.ts +0 -372
  147. package/src/types.ts +0 -2123
  148. package/src/url.ts +0 -131
  149. package/src/utils/index.ts +0 -1
  150. package/src/utils/query-preservation.ts +0 -201
  151. package/src/utils.ts +0 -395
  152. package/src/validation/validator.ts +0 -688
  153. package/src/websocket/clustering.ts +0 -769
@@ -1,489 +0,0 @@
1
- /**
2
- * Request/Response Type Augmentation Based on Middleware
3
- *
4
- * Advanced TypeScript utilities for augmenting request/response types through middleware
5
- */
6
-
7
- import type {
8
- AuthenticatedRequest,
9
- AuthorizedRequest,
10
- CachedRequest,
11
- CORSRequest,
12
- FileUploadRequest,
13
- LoggedRequest,
14
- RateLimitedRequest,
15
- SessionRequest,
16
- TypedMiddleware,
17
- ValidatedRequest,
18
- } from './middleware-types'
19
- import type {
20
- ExtractQueryParams,
21
- ExtractTypedParams,
22
- TypedRequest,
23
- } from './route-inference'
24
-
25
- // Base augmentation interface
26
- export interface RequestAugmentation {
27
- [key: string]: any
28
- }
29
-
30
- export interface ResponseAugmentation {
31
- [key: string]: any
32
- }
33
-
34
- // Middleware augmentation extraction
35
- export type ExtractMiddlewareAugmentation<T> =
36
- T extends TypedMiddleware<infer Input, infer Output, infer Context, any>
37
- ? {
38
- input: Input
39
- output: Output
40
- context: Context
41
- augmentation: Output extends Input & infer Aug ? Aug : object
42
- }
43
- : never
44
-
45
- // Request augmentation through middleware chain
46
- export type AugmentRequestThroughChain<
47
- TRequest,
48
- TMiddlewares extends readonly TypedMiddleware<any, any, any, any>[],
49
- > = TMiddlewares extends readonly [infer First, ...infer Rest]
50
- ? First extends TypedMiddleware<TRequest, infer Output, any, any>
51
- ? Rest extends readonly TypedMiddleware<any, any, any, any>[]
52
- ? AugmentRequestThroughChain<Output, Rest>
53
- : Output
54
- : TRequest
55
- : TRequest
56
-
57
- // Context accumulation through middleware chain
58
- export type AccumulateContext<
59
- TMiddlewares extends readonly TypedMiddleware<any, any, any, any>[],
60
- > = TMiddlewares extends readonly [infer First, ...infer Rest]
61
- ? First extends TypedMiddleware<any, any, infer Context, any>
62
- ? Rest extends readonly TypedMiddleware<any, any, any, any>[]
63
- ? Context & AccumulateContext<Rest>
64
- : Context
65
- : object
66
- : object
67
-
68
- // Enhanced request with middleware augmentations
69
- export type EnhancedRequest<
70
- TPath extends string = string,
71
- TQuery extends Record<string, any> = object,
72
- TBody = unknown,
73
- TContext = object,
74
- TAugmentations = object,
75
- > = TypedRequest<TPath, TQuery, TBody, TContext> & {
76
- // Core request properties
77
- params: ExtractTypedParams<TPath>
78
- query: ExtractQueryParams<TQuery>
79
- body: TBody
80
- context: TContext & TAugmentations
81
-
82
- // Middleware augmentations (conditionally added)
83
- user?: TAugmentations extends { auth: any }
84
- ? TAugmentations['auth']['user']
85
- : never
86
-
87
- isAuthenticated?: TAugmentations extends { auth: any }
88
- ? boolean
89
- : never
90
-
91
- permissions?: TAugmentations extends { authz: any }
92
- ? TAugmentations['authz']['permissions']
93
- : never
94
-
95
- hasPermission?: TAugmentations extends { authz: any }
96
- ? (_permission: string) => boolean
97
- : never
98
-
99
- validatedParams?: TAugmentations extends { validation: any }
100
- ? TAugmentations['validation']['params']
101
- : never
102
-
103
- validatedQuery?: TAugmentations extends { validation: any }
104
- ? TAugmentations['validation']['query']
105
- : never
106
-
107
- validatedBody?: TAugmentations extends { validation: any }
108
- ? TAugmentations['validation']['body']
109
- : never
110
-
111
- rateLimit?: TAugmentations extends { rateLimit: any }
112
- ? TAugmentations['rateLimit']
113
- : never
114
-
115
- cache?: TAugmentations extends { cache: any }
116
- ? TAugmentations['cache']
117
- : never
118
-
119
- requestId?: TAugmentations extends { logging: any }
120
- ? string
121
- : never
122
-
123
- logger?: TAugmentations extends { logging: any }
124
- ? TAugmentations['logging']['logger']
125
- : never
126
-
127
- cors?: TAugmentations extends { cors: any }
128
- ? TAugmentations['cors']
129
- : never
130
-
131
- files?: TAugmentations extends { upload: any }
132
- ? TAugmentations['upload']['files']
133
- : never
134
-
135
- session?: TAugmentations extends { session: any }
136
- ? TAugmentations['session']
137
- : never
138
- }
139
-
140
- // Enhanced response with middleware augmentations
141
- export interface EnhancedResponse<TAugmentations = object> extends Response {
142
- // Middleware-added properties
143
- cached?: TAugmentations extends { cache: any }
144
- ? boolean
145
- : never
146
-
147
- rateLimited?: TAugmentations extends { rateLimit: any }
148
- ? boolean
149
- : never
150
-
151
- requestId?: TAugmentations extends { logging: any }
152
- ? string
153
- : never
154
-
155
- executionTime?: TAugmentations extends { logging: any }
156
- ? number
157
- : never
158
- }
159
-
160
- // Middleware-aware route handler
161
- export type AugmentedRouteHandler<
162
- TPath extends string,
163
- TQuery extends Record<string, any> = object,
164
- TBody = unknown,
165
- TContext = object,
166
- TMiddlewares extends readonly TypedMiddleware<any, any, any, any>[] = [],
167
- > = (
168
- request: EnhancedRequest<
169
- TPath,
170
- TQuery,
171
- TBody,
172
- TContext,
173
- AccumulateContext<TMiddlewares>
174
- >
175
- ) => Promise<EnhancedResponse<AccumulateContext<TMiddlewares>>> | EnhancedResponse<AccumulateContext<TMiddlewares>>
176
-
177
- // Type-safe middleware application
178
- export type ApplyMiddleware<
179
- TRequest,
180
- TMiddleware extends TypedMiddleware<any, any, any, any>,
181
- > = TMiddleware extends TypedMiddleware<TRequest, infer Output, infer Context, any>
182
- ? {
183
- request: Output
184
- context: Context
185
- }
186
- : never
187
-
188
- // Sequential middleware application
189
- export type ApplyMiddlewareSequence<
190
- TRequest,
191
- TMiddlewares extends readonly TypedMiddleware<any, any, any, any>[],
192
- > = TMiddlewares extends readonly [infer First, ...infer Rest]
193
- ? First extends TypedMiddleware<TRequest, infer Output, infer Context, any>
194
- ? Rest extends readonly TypedMiddleware<any, any, any, any>[]
195
- ? ApplyMiddlewareSequence<Output, Rest> extends {
196
- request: infer FinalRequest
197
- context: infer RestContext
198
- }
199
- ? {
200
- request: FinalRequest
201
- context: Context & RestContext
202
- }
203
- : {
204
- request: Output
205
- context: Context
206
- }
207
- : {
208
- request: Output
209
- context: Context
210
- }
211
- : {
212
- request: TRequest
213
- context: object
214
- }
215
- : {
216
- request: TRequest
217
- context: object
218
- }
219
-
220
- // Conditional augmentation based on middleware presence
221
- export type ConditionalAugmentation<
222
- TMiddlewares extends readonly TypedMiddleware<any, any, any, any>[],
223
- TAugmentation,
224
- > = TMiddlewares extends readonly []
225
- ? object
226
- : TAugmentation
227
-
228
- // Authentication augmentation
229
- export type AuthAugmentation<TUser = any> = ConditionalAugmentation<
230
- [TypedMiddleware<any, any, { auth: { user: TUser } }, any>],
231
- AuthenticatedRequest<TUser>
232
- >
233
-
234
- // Authorization augmentation
235
- export type AuthzAugmentation<TPermissions extends string = string> = ConditionalAugmentation<
236
- [TypedMiddleware<any, any, { authz: { permissions: TPermissions[] } }, any>],
237
- AuthorizedRequest<TPermissions>
238
- >
239
-
240
- // Validation augmentation
241
- export type ValidationAugmentation<TParams = any, TQuery = any, TBody = any> = ConditionalAugmentation<
242
- [TypedMiddleware<any, any, { validation: { params: TParams, query: TQuery, body: TBody } }, any>],
243
- ValidatedRequest<TParams, TQuery, TBody>
244
- >
245
-
246
- // Rate limiting augmentation
247
- export type RateLimitAugmentation = ConditionalAugmentation<
248
- [TypedMiddleware<any, any, { rateLimit: RateLimitedRequest['rateLimit'] }, any>],
249
- RateLimitedRequest
250
- >
251
-
252
- // Caching augmentation
253
- export type CacheAugmentation = ConditionalAugmentation<
254
- [TypedMiddleware<any, any, { cache: CachedRequest['cache'] }, any>],
255
- CachedRequest
256
- >
257
-
258
- // Logging augmentation
259
- export type LoggingAugmentation = ConditionalAugmentation<
260
- [TypedMiddleware<any, any, { logging: { requestId: string, logger: LoggedRequest['logger'] } }, any>],
261
- LoggedRequest
262
- >
263
-
264
- // CORS augmentation
265
- export type CORSAugmentation = ConditionalAugmentation<
266
- [TypedMiddleware<any, any, { cors: CORSRequest['cors'] }, any>],
267
- CORSRequest
268
- >
269
-
270
- // File upload augmentation
271
- export type FileUploadAugmentation<TFiles extends Record<string, any> = Record<string, File>> = ConditionalAugmentation<
272
- [TypedMiddleware<any, any, { upload: { files: TFiles } }, any>],
273
- FileUploadRequest<TFiles>
274
- >
275
-
276
- // Session augmentation
277
- export type SessionAugmentation<TSession = any> = ConditionalAugmentation<
278
- [TypedMiddleware<any, any, { session: SessionRequest<TSession>['session'] }, any>],
279
- SessionRequest<TSession>
280
- >
281
-
282
- // Combined augmentations
283
- export type CombineAugmentations<T extends Record<string, any>[]> = T extends [
284
- infer First,
285
- ...infer Rest,
286
- ]
287
- ? First extends Record<string, any>
288
- ? Rest extends Record<string, any>[]
289
- ? First & CombineAugmentations<Rest>
290
- : First
291
- : object
292
- : object
293
-
294
- // Middleware type detection
295
- export type HasAuthMiddleware<T extends readonly TypedMiddleware<any, any, any, any>[]> =
296
- T extends readonly [infer First, ...infer Rest]
297
- ? First extends TypedMiddleware<any, any, { auth: any }, any>
298
- ? true
299
- : Rest extends readonly TypedMiddleware<any, any, any, any>[]
300
- ? HasAuthMiddleware<Rest>
301
- : false
302
- : false
303
-
304
- export type HasValidationMiddleware<T extends readonly TypedMiddleware<any, any, any, any>[]> =
305
- T extends readonly [infer First, ...infer Rest]
306
- ? First extends TypedMiddleware<any, any, { validation: any }, any>
307
- ? true
308
- : Rest extends readonly TypedMiddleware<any, any, any, any>[]
309
- ? HasValidationMiddleware<Rest>
310
- : false
311
- : false
312
-
313
- export type HasRateLimitMiddleware<T extends readonly TypedMiddleware<any, any, any, any>[]> =
314
- T extends readonly [infer First, ...infer Rest]
315
- ? First extends TypedMiddleware<any, any, { rateLimit: any }, any>
316
- ? true
317
- : Rest extends readonly TypedMiddleware<any, any, any, any>[]
318
- ? HasRateLimitMiddleware<Rest>
319
- : false
320
- : false
321
-
322
- // Augmentation builder
323
- export interface AugmentationBuilder<TBase = Request> {
324
- withAuth: <TUser>(
325
- middleware: TypedMiddleware<any, any, { auth: { user: TUser } }, any>
326
- ) => AugmentationBuilder<TBase & AuthenticatedRequest<TUser>>
327
-
328
- withValidation: <TParams, TQuery, TBody>(
329
- middleware: TypedMiddleware<any, any, { validation: { params: TParams, query: TQuery, body: TBody } }, any>
330
- ) => AugmentationBuilder<TBase & ValidatedRequest<TParams, TQuery, TBody>>
331
-
332
- withRateLimit: (
333
- middleware: TypedMiddleware<any, any, { rateLimit: RateLimitedRequest['rateLimit'] }, any>
334
- ) => AugmentationBuilder<TBase & RateLimitedRequest>
335
-
336
- withCache: (
337
- middleware: TypedMiddleware<any, any, { cache: CachedRequest['cache'] }, any>
338
- ) => AugmentationBuilder<TBase & CachedRequest>
339
-
340
- withLogging: (
341
- middleware: TypedMiddleware<any, any, { logging: { requestId: string, logger: LoggedRequest['logger'] } }, any>
342
- ) => AugmentationBuilder<TBase & LoggedRequest>
343
-
344
- withCORS: (
345
- middleware: TypedMiddleware<any, any, { cors: CORSRequest['cors'] }, any>
346
- ) => AugmentationBuilder<TBase & CORSRequest>
347
-
348
- withFileUpload: <TFiles extends Record<string, any>>(
349
- middleware: TypedMiddleware<any, any, { upload: { files: TFiles } }, any>
350
- ) => AugmentationBuilder<TBase & FileUploadRequest<TFiles>>
351
-
352
- withSession: <TSession>(
353
- middleware: TypedMiddleware<any, any, { session: SessionRequest<TSession>['session'] }, any>
354
- ) => AugmentationBuilder<TBase & SessionRequest<TSession>>
355
-
356
- build: () => TBase
357
- }
358
-
359
- // Route with augmented types
360
- export interface AugmentedRoute<
361
- TPath extends string,
362
- TQuery extends Record<string, any> = object,
363
- TBody = unknown,
364
- TContext = object,
365
- TMiddlewares extends readonly TypedMiddleware<any, any, any, any>[] = [],
366
- > {
367
- method: string
368
- path: TPath
369
- handler: AugmentedRouteHandler<TPath, TQuery, TBody, TContext, TMiddlewares>
370
- middleware: TMiddlewares
371
- augmentedRequest: EnhancedRequest<TPath, TQuery, TBody, TContext, AccumulateContext<TMiddlewares>>
372
- augmentedResponse: EnhancedResponse<AccumulateContext<TMiddlewares>>
373
- }
374
-
375
- // Type-safe route builder with augmentation
376
- export interface AugmentedRouteBuilder<TContext = object> {
377
- get: <
378
- TPath extends string,
379
- TQuery extends Record<string, any> = object,
380
- TMiddlewares extends readonly TypedMiddleware<any, any, any, any>[] = [],
381
- >(
382
- path: TPath,
383
- middleware: TMiddlewares,
384
- handler: AugmentedRouteHandler<TPath, TQuery, never, TContext, TMiddlewares>
385
- ) => AugmentedRoute<TPath, TQuery, never, TContext, TMiddlewares>
386
-
387
- post: <
388
- TPath extends string,
389
- TQuery extends Record<string, any> = object,
390
- TBody = unknown,
391
- TMiddlewares extends readonly TypedMiddleware<any, any, any, any>[] = [],
392
- >(
393
- path: TPath,
394
- middleware: TMiddlewares,
395
- handler: AugmentedRouteHandler<TPath, TQuery, TBody, TContext, TMiddlewares>
396
- ) => AugmentedRoute<TPath, TQuery, TBody, TContext, TMiddlewares>
397
-
398
- put: <
399
- TPath extends string,
400
- TQuery extends Record<string, any> = object,
401
- TBody = unknown,
402
- TMiddlewares extends readonly TypedMiddleware<any, any, any, any>[] = [],
403
- >(
404
- path: TPath,
405
- middleware: TMiddlewares,
406
- handler: AugmentedRouteHandler<TPath, TQuery, TBody, TContext, TMiddlewares>
407
- ) => AugmentedRoute<TPath, TQuery, TBody, TContext, TMiddlewares>
408
-
409
- patch: <
410
- TPath extends string,
411
- TQuery extends Record<string, any> = object,
412
- TBody = unknown,
413
- TMiddlewares extends readonly TypedMiddleware<any, any, any, any>[] = [],
414
- >(
415
- path: TPath,
416
- middleware: TMiddlewares,
417
- handler: AugmentedRouteHandler<TPath, TQuery, TBody, TContext, TMiddlewares>
418
- ) => AugmentedRoute<TPath, TQuery, TBody, TContext, TMiddlewares>
419
-
420
- delete: <
421
- TPath extends string,
422
- TQuery extends Record<string, any> = object,
423
- TMiddlewares extends readonly TypedMiddleware<any, any, any, any>[] = [],
424
- >(
425
- path: TPath,
426
- middleware: TMiddlewares,
427
- handler: AugmentedRouteHandler<TPath, TQuery, never, TContext, TMiddlewares>
428
- ) => AugmentedRoute<TPath, TQuery, never, TContext, TMiddlewares>
429
- }
430
-
431
- // Augmentation validation
432
- export type ValidateAugmentation<
433
- TRequest,
434
- TExpectedAugmentation,
435
- > = TRequest extends TExpectedAugmentation
436
- ? true
437
- : false
438
-
439
- // Augmentation compatibility checking
440
- export type AugmentationCompatible<
441
- TMiddleware1 extends TypedMiddleware<any, any, any, any>,
442
- TMiddleware2 extends TypedMiddleware<any, any, any, any>,
443
- > = TMiddleware1 extends TypedMiddleware<any, infer Output1, any, any>
444
- ? TMiddleware2 extends TypedMiddleware<Output1, any, any, any>
445
- ? true
446
- : false
447
- : false
448
-
449
- // Runtime augmentation helpers
450
- export interface RuntimeAugmentation {
451
- augmentRequest: <T>(request: Request, augmentation: T) => Request & T
452
- extractAugmentation: <T>(request: Request & T) => T
453
- hasAugmentation: <T>(request: Request, key: keyof T) => boolean
454
- getAugmentation: <T, K extends keyof T>(request: Request & T, key: K) => T[K]
455
- }
456
-
457
- // Augmentation metadata
458
- export interface AugmentationMetadata {
459
- name: string
460
- version?: string
461
- description?: string
462
- dependencies?: string[]
463
- provides: string[]
464
- requires?: string[]
465
- }
466
-
467
- // Augmentation registry
468
- export interface AugmentationRegistry {
469
- register: (
470
- name: string,
471
- middleware: TypedMiddleware<any, any, any, any>,
472
- metadata: AugmentationMetadata
473
- ) => void
474
-
475
- get: (name: string) => {
476
- middleware: TypedMiddleware<any, any, any, any>
477
- metadata: AugmentationMetadata
478
- } | undefined
479
-
480
- resolve: (requirements: string[]) => TypedMiddleware<any, any, any, any>[]
481
-
482
- validate: (middlewares: TypedMiddleware<any, any, any, any>[]) => {
483
- valid: boolean
484
- errors: string[]
485
- warnings: string[]
486
- }
487
- }
488
-
489
- // Types are already exported above via individual export statements