@stacksjs/bun-router 0.0.16 → 0.0.18

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 (176) hide show
  1. package/dist/auth.d.ts +22 -8
  2. package/dist/chunk-1ahs68ys.js +18 -0
  3. package/dist/{chunk-0145g1me.js → chunk-cgptvjdf.js} +147 -75
  4. package/dist/chunk-g3ybefhg.js +1923 -0
  5. package/dist/cli.js +3 -2
  6. package/dist/container/container.d.ts +1 -0
  7. package/dist/container/contextual-binding.d.ts +0 -1
  8. package/dist/container/decorators.d.ts +2 -5
  9. package/dist/container/index.d.ts +16 -0
  10. package/dist/container/index.js +322 -0
  11. package/dist/container/service-provider.d.ts +3 -3
  12. package/dist/development/performance-profiler.d.ts +3 -3
  13. package/dist/development/route-debugger.d.ts +1 -1
  14. package/dist/development/route-inspector.d.ts +2 -2
  15. package/dist/file-serving/static-files.d.ts +16 -0
  16. package/dist/index.d.ts +17 -1
  17. package/dist/index.js +1159 -1380
  18. package/dist/middleware/cors.d.ts +9 -0
  19. package/dist/middleware/csrf.d.ts +7 -0
  20. package/dist/middleware/ddos_protection.d.ts +16 -1
  21. package/dist/middleware/rate_limit.d.ts +7 -1
  22. package/dist/middleware/request_tracer.d.ts +15 -9
  23. package/dist/middleware/response_cache.d.ts +2 -1
  24. package/dist/observability/integration.d.ts +1 -1
  25. package/dist/request/context.d.ts +12 -1
  26. package/dist/request/macros.d.ts +40 -2
  27. package/dist/response/macros.d.ts +4 -4
  28. package/dist/router/fluent-routing.d.ts +50 -13
  29. package/dist/router/handler-resolver.d.ts +8 -0
  30. package/dist/router/index.d.ts +9 -7
  31. package/dist/router/route-compiler.d.ts +8 -10
  32. package/dist/router/route-trie.d.ts +7 -1
  33. package/dist/router/router.d.ts +13 -34
  34. package/dist/router/validation-integration.d.ts +10 -4
  35. package/dist/testing/performance-testing.d.ts +2 -2
  36. package/dist/testing/test-client.d.ts +1 -1
  37. package/dist/testing/websocket-testing.d.ts +1 -1
  38. package/dist/types/middleware-types.d.ts +1 -1
  39. package/dist/types/route-inference.d.ts +9 -2
  40. package/dist/types.d.ts +62 -9
  41. package/dist/utils.d.ts +1 -1
  42. package/package.json +12 -3
  43. package/dist/router/fluent-router.d.ts +0 -315
  44. package/src/auth.ts +0 -469
  45. package/src/cache/lru-cache.ts +0 -457
  46. package/src/cache/middleware-memoization.ts +0 -531
  47. package/src/cache/route-cache-warmer.ts +0 -486
  48. package/src/cache/sqlite-cache.ts +0 -783
  49. package/src/cache/streaming-cache.ts +0 -572
  50. package/src/cli/colors.ts +0 -29
  51. package/src/cli/index.ts +0 -287
  52. package/src/cli/middleware.ts +0 -291
  53. package/src/cli/openapi.ts +0 -407
  54. package/src/cli/router.ts +0 -188
  55. package/src/cli/routes.ts +0 -265
  56. package/src/cli/utils.ts +0 -531
  57. package/src/cli.ts +0 -5
  58. package/src/config.ts +0 -322
  59. package/src/container/container.ts +0 -740
  60. package/src/container/contextual-binding.ts +0 -603
  61. package/src/container/decorators.ts +0 -359
  62. package/src/container/service-provider.ts +0 -596
  63. package/src/development/hot-reload.ts +0 -673
  64. package/src/development/index.ts +0 -499
  65. package/src/development/performance-profiler.ts +0 -717
  66. package/src/development/route-debugger.ts +0 -527
  67. package/src/development/route-inspector.ts +0 -749
  68. package/src/development/typescript-utilities.ts +0 -682
  69. package/src/docs.ts +0 -397
  70. package/src/errors/circuit-breaker.ts +0 -732
  71. package/src/errors/error-handler.ts +0 -569
  72. package/src/errors/error-reporting.ts +0 -672
  73. package/src/errors/exceptions.ts +0 -536
  74. package/src/errors/graceful-degradation.ts +0 -621
  75. package/src/errors/index.ts +0 -21
  76. package/src/errors/router-errors.ts +0 -632
  77. package/src/file-serving/static-files.ts +0 -581
  78. package/src/index.ts +0 -14
  79. package/src/middleware/auth.ts +0 -220
  80. package/src/middleware/content_security_policy.ts +0 -215
  81. package/src/middleware/cors.ts +0 -74
  82. package/src/middleware/csrf.ts +0 -118
  83. package/src/middleware/ddos_protection.ts +0 -255
  84. package/src/middleware/file_security.ts +0 -191
  85. package/src/middleware/file_upload.ts +0 -275
  86. package/src/middleware/helmet.ts +0 -268
  87. package/src/middleware/index.ts +0 -117
  88. package/src/middleware/input_validation.ts +0 -449
  89. package/src/middleware/json_body.ts +0 -37
  90. package/src/middleware/performance_alerting.ts +0 -538
  91. package/src/middleware/performance_dashboard.ts +0 -661
  92. package/src/middleware/performance_monitor.ts +0 -943
  93. package/src/middleware/pipeline.ts +0 -489
  94. package/src/middleware/rate_limit.ts +0 -245
  95. package/src/middleware/request_id.ts +0 -36
  96. package/src/middleware/request_signing.ts +0 -636
  97. package/src/middleware/request_tracer.ts +0 -636
  98. package/src/middleware/response_cache.ts +0 -743
  99. package/src/middleware/security.ts +0 -482
  100. package/src/middleware/security_suite.ts +0 -257
  101. package/src/middleware/session.ts +0 -91
  102. package/src/model-binding/index.ts +0 -18
  103. package/src/model-binding/model-middleware.ts +0 -425
  104. package/src/model-binding/model-registry.ts +0 -550
  105. package/src/model-binding.ts +0 -370
  106. package/src/model-resolver-factory.ts +0 -106
  107. package/src/observability/correlation.ts +0 -691
  108. package/src/observability/health-checks.ts +0 -729
  109. package/src/observability/index.ts +0 -184
  110. package/src/observability/integration.ts +0 -548
  111. package/src/observability/metrics.ts +0 -753
  112. package/src/observability/tracing.ts +0 -638
  113. package/src/optimization/bun-utilities.ts +0 -778
  114. package/src/query-builder-integration.ts +0 -137
  115. package/src/request/context.ts +0 -62
  116. package/src/request/enhanced-request.ts +0 -857
  117. package/src/request/macros.ts +0 -688
  118. package/src/response/macros.ts +0 -665
  119. package/src/response/response-factory.ts +0 -596
  120. package/src/router/api-routes.ts +0 -243
  121. package/src/router/file-based-routing.ts +0 -690
  122. package/src/router/file-streaming.ts +0 -383
  123. package/src/router/fluent-router.ts +0 -927
  124. package/src/router/fluent-routing.ts +0 -797
  125. package/src/router/group-organization.ts +0 -213
  126. package/src/router/handler-resolver.ts +0 -291
  127. package/src/router/http-methods.ts +0 -377
  128. package/src/router/index.ts +0 -187
  129. package/src/router/middleware-groups.ts +0 -222
  130. package/src/router/middleware-integration.ts +0 -399
  131. package/src/router/middleware.ts +0 -231
  132. package/src/router/model-binding.ts +0 -215
  133. package/src/router/optimized-route-matching.ts +0 -253
  134. package/src/router/route-building.ts +0 -221
  135. package/src/router/route-compiler.ts +0 -702
  136. package/src/router/route-matching.ts +0 -349
  137. package/src/router/route-trie.ts +0 -464
  138. package/src/router/router.ts +0 -1604
  139. package/src/router/server.ts +0 -462
  140. package/src/router/validation-integration.ts +0 -443
  141. package/src/router/view-rendering.ts +0 -233
  142. package/src/router/websocket.ts +0 -100
  143. package/src/routing/route-caching.ts +0 -402
  144. package/src/routing/route-throttling.ts +0 -469
  145. package/src/routing/subdomain-routing.ts +0 -492
  146. package/src/session/database-store.ts +0 -109
  147. package/src/session/file-store.ts +0 -148
  148. package/src/session/index.ts +0 -244
  149. package/src/session/memory-store.ts +0 -88
  150. package/src/session/redis-store.ts +0 -93
  151. package/src/streaming/index.ts +0 -17
  152. package/src/streaming/sse-handler.ts +0 -482
  153. package/src/streaming/stream-handler.ts +0 -552
  154. package/src/testing/auth-testing.ts +0 -446
  155. package/src/testing/file-upload-testing.ts +0 -543
  156. package/src/testing/index.ts +0 -10
  157. package/src/testing/middleware-testing.ts +0 -322
  158. package/src/testing/model-binding-testing.ts +0 -645
  159. package/src/testing/performance-testing.ts +0 -738
  160. package/src/testing/test-client.ts +0 -310
  161. package/src/testing/test-request.ts +0 -315
  162. package/src/testing/test-response.ts +0 -332
  163. package/src/testing/types.ts +0 -224
  164. package/src/testing/websocket-testing.ts +0 -590
  165. package/src/types/controller-types.ts +0 -385
  166. package/src/types/core.ts +0 -683
  167. package/src/types/middleware-types.ts +0 -419
  168. package/src/types/request-response-augmentation.ts +0 -489
  169. package/src/types/route-inference.ts +0 -357
  170. package/src/types.ts +0 -2067
  171. package/src/url.ts +0 -126
  172. package/src/utils/index.ts +0 -1
  173. package/src/utils/query-preservation.ts +0 -201
  174. package/src/utils.ts +0 -392
  175. package/src/validation/validator.ts +0 -685
  176. package/src/websocket/clustering.ts +0 -762
package/src/types/core.ts DELETED
@@ -1,683 +0,0 @@
1
- /**
2
- * Core Type Definitions
3
- *
4
- * Narrowly typed interfaces to replace all `any` types throughout the codebase.
5
- * These types provide strict type safety while maintaining flexibility.
6
- */
7
-
8
- import type { ServerWebSocket } from 'bun'
9
-
10
- // ============================================================================
11
- // OAuth2 Types
12
- // ============================================================================
13
-
14
- /**
15
- * OAuth2 Authorization Code Flow configuration
16
- */
17
- export interface OAuth2AuthorizationCodeFlow {
18
- authorizationUrl: string
19
- tokenUrl: string
20
- refreshUrl?: string
21
- scopes: Record<string, string>
22
- }
23
-
24
- /**
25
- * OAuth2 Implicit Flow configuration
26
- */
27
- export interface OAuth2ImplicitFlow {
28
- authorizationUrl: string
29
- refreshUrl?: string
30
- scopes: Record<string, string>
31
- }
32
-
33
- /**
34
- * OAuth2 Client Credentials Flow configuration
35
- */
36
- export interface OAuth2ClientCredentialsFlow {
37
- tokenUrl: string
38
- refreshUrl?: string
39
- scopes: Record<string, string>
40
- }
41
-
42
- /**
43
- * OAuth2 Password Flow configuration
44
- */
45
- export interface OAuth2PasswordFlow {
46
- tokenUrl: string
47
- refreshUrl?: string
48
- scopes: Record<string, string>
49
- }
50
-
51
- /**
52
- * OAuth2 Flows configuration - replaces `flows?: any`
53
- */
54
- export interface OAuth2Flows {
55
- implicit?: OAuth2ImplicitFlow
56
- password?: OAuth2PasswordFlow
57
- clientCredentials?: OAuth2ClientCredentialsFlow
58
- authorizationCode?: OAuth2AuthorizationCodeFlow
59
- }
60
-
61
- /**
62
- * OAuth2 Profile from provider - replaces `profile: any`
63
- */
64
- export interface OAuth2Profile {
65
- id: string
66
- provider: string
67
- email?: string
68
- emailVerified?: boolean
69
- name?: string
70
- firstName?: string
71
- lastName?: string
72
- displayName?: string
73
- username?: string
74
- avatar?: string
75
- profileUrl?: string
76
- locale?: string
77
- timezone?: string
78
- raw?: Record<string, unknown>
79
- }
80
-
81
- // ============================================================================
82
- // Session Types
83
- // ============================================================================
84
-
85
- /**
86
- * Session data interface - replaces `session?: any`
87
- */
88
- export interface SessionData {
89
- id?: string
90
- userId?: string
91
- createdAt?: number
92
- expiresAt?: number
93
- data?: Record<string, unknown>
94
- flash?: Record<string, unknown>
95
- csrfToken?: string
96
- regenerate?: () => Promise<void>
97
- destroy?: () => Promise<void>
98
- save?: () => Promise<void>
99
- touch?: () => Promise<void>
100
- [key: string]: unknown
101
- }
102
-
103
- /**
104
- * Session serializer interface - replaces serializer with `any`
105
- */
106
- export interface SessionSerializer<T = SessionData> {
107
- stringify: (data: T) => string
108
- parse: (data: string) => T
109
- }
110
-
111
- /**
112
- * Session store interface - replaces custom store with `any`
113
- */
114
- export interface SessionStore<T = SessionData> {
115
- get: (sid: string) => Promise<T | null>
116
- set: (sid: string, session: T, ttl?: number) => Promise<void>
117
- destroy: (sid: string) => Promise<void>
118
- touch?: (sid: string, session: T, ttl?: number) => Promise<void>
119
- all?: () => Promise<Record<string, T>>
120
- length?: () => Promise<number>
121
- clear?: () => Promise<void>
122
- }
123
-
124
- // ============================================================================
125
- // User & Authentication Types
126
- // ============================================================================
127
-
128
- /**
129
- * Base user interface - replaces `user?: any`
130
- */
131
- export interface User {
132
- id: string | number
133
- email?: string
134
- name?: string
135
- username?: string
136
- roles?: string[]
137
- permissions?: string[]
138
- emailVerifiedAt?: Date | null
139
- createdAt?: Date
140
- updatedAt?: Date
141
- metadata?: Record<string, unknown>
142
- plan?: string
143
- [key: string]: unknown
144
- }
145
-
146
- /**
147
- * Authenticated user with additional auth context
148
- */
149
- export interface AuthenticatedUser extends User {
150
- tokenType?: 'jwt' | 'session' | 'apikey' | 'bearer'
151
- tokenExpiry?: number
152
- scopes?: string[]
153
- isAdmin?: boolean
154
- isSuperAdmin?: boolean
155
- }
156
-
157
- /**
158
- * Auth context - replaces `auth?: any`
159
- */
160
- export interface AuthContext<TUser extends User = User> {
161
- user: TUser | null
162
- isAuthenticated: boolean
163
- check: () => boolean
164
- guest: () => boolean
165
- id: () => string | number | null
166
- validate: (credentials: { email: string, password: string }) => Promise<TUser | null>
167
- attempt: (credentials: { email: string, password: string }, remember?: boolean) => Promise<boolean>
168
- login: (user: TUser, remember?: boolean) => Promise<void>
169
- logout: () => Promise<void>
170
- hasRole: (role: string | string[]) => boolean
171
- hasPermission: (permission: string | string[]) => boolean
172
- can: (ability: string, resource?: unknown) => boolean
173
- }
174
-
175
- // ============================================================================
176
- // Metrics & Monitoring Types
177
- // ============================================================================
178
-
179
- /**
180
- * Metric entry interface - replaces `metrics: any[]`
181
- */
182
- export interface MetricEntry {
183
- name: string
184
- value: number
185
- timestamp: number
186
- type: 'counter' | 'gauge' | 'histogram' | 'summary'
187
- tags?: Record<string, string>
188
- unit?: string
189
- description?: string
190
- }
191
-
192
- /**
193
- * Performance metric
194
- */
195
- export interface PerformanceMetric extends MetricEntry {
196
- type: 'histogram'
197
- percentiles?: {
198
- p50: number
199
- p75: number
200
- p90: number
201
- p95: number
202
- p99: number
203
- }
204
- min?: number
205
- max?: number
206
- avg?: number
207
- count?: number
208
- }
209
-
210
- /**
211
- * Trace span attributes - replaces `attributes: Record<string, any>`
212
- */
213
- export interface TraceAttributes {
214
- 'http.method'?: string
215
- 'http.url'?: string
216
- 'http.status_code'?: number
217
- 'http.route'?: string
218
- 'http.user_agent'?: string
219
- 'http.request_content_length'?: number
220
- 'http.response_content_length'?: number
221
- 'net.peer.ip'?: string
222
- 'net.peer.port'?: number
223
- 'db.system'?: string
224
- 'db.statement'?: string
225
- 'db.operation'?: string
226
- 'error'?: boolean
227
- 'error.message'?: string
228
- 'error.stack'?: string
229
- [key: string]: string | number | boolean | undefined
230
- }
231
-
232
- /**
233
- * Trace span interface
234
- */
235
- export interface TraceSpan {
236
- name: string
237
- traceId: string
238
- spanId: string
239
- parentSpanId?: string
240
- startTime: number
241
- endTime?: number
242
- duration?: number
243
- status: 'OK' | 'ERROR' | 'UNSET'
244
- attributes: TraceAttributes
245
- events?: TraceEvent[]
246
- }
247
-
248
- /**
249
- * Trace event
250
- */
251
- export interface TraceEvent {
252
- name: string
253
- timestamp: number
254
- attributes?: TraceAttributes
255
- }
256
-
257
- // ============================================================================
258
- // WebSocket Types
259
- // ============================================================================
260
-
261
- /**
262
- * WebSocket data interface - replaces `ServerWebSocket<any>`
263
- */
264
- export interface WebSocketData {
265
- id: string
266
- userId?: string | number
267
- channels?: Set<string>
268
- metadata?: Record<string, unknown>
269
- connectedAt: number
270
- lastPingAt?: number
271
- ip?: string
272
- userAgent?: string
273
- }
274
-
275
- /**
276
- * Typed ServerWebSocket
277
- */
278
- export type TypedServerWebSocket<T extends WebSocketData = WebSocketData> = ServerWebSocket<T>
279
-
280
- // ============================================================================
281
- // Validation Types
282
- // ============================================================================
283
-
284
- /**
285
- * Validation schema - replaces `schemas?: Record<string, any>`
286
- */
287
- export interface ValidationSchema {
288
- type?: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'date' | 'email' | 'url' | 'uuid'
289
- required?: boolean
290
- nullable?: boolean
291
- default?: unknown
292
- rules?: ValidationRule[]
293
- message?: string
294
- transform?: (value: unknown) => unknown
295
- [key: string]: ValidationRule | ValidationSchema | unknown
296
- }
297
-
298
- /**
299
- * Validation rule
300
- */
301
- export interface ValidationRule {
302
- name: string
303
- params?: unknown[]
304
- message?: string
305
- }
306
-
307
- /**
308
- * Input validation schemas
309
- */
310
- export interface InputValidationSchemas {
311
- query?: ValidationSchema
312
- body?: ValidationSchema
313
- headers?: ValidationSchema
314
- params?: ValidationSchema
315
- }
316
-
317
- // ============================================================================
318
- // Sanitization Types
319
- // ============================================================================
320
-
321
- /**
322
- * Sanitization options - replaces `options?: any`
323
- */
324
- export interface SanitizationOptions {
325
- trim?: boolean
326
- lowercase?: boolean
327
- uppercase?: boolean
328
- escape?: boolean
329
- stripTags?: boolean
330
- normalizeEmail?: boolean
331
- toInt?: boolean
332
- toFloat?: boolean
333
- toBoolean?: boolean
334
- toDate?: boolean
335
- customSanitizer?: (value: unknown) => unknown
336
- }
337
-
338
- /**
339
- * Sanitization rule configuration
340
- */
341
- export interface SanitizationRule {
342
- type: 'escape' | 'strip' | 'validate' | 'transform'
343
- options: SanitizationOptions
344
- }
345
-
346
- // ============================================================================
347
- // Template & View Types
348
- // ============================================================================
349
-
350
- /**
351
- * Template helper function signature - replaces `(...args: any[]) => any`
352
- */
353
- export type TemplateHelper = (..._args: unknown[]) => string | number | boolean | null | undefined
354
-
355
- /**
356
- * Template helpers map
357
- */
358
- export type TemplateHelpers = Record<string, TemplateHelper>
359
-
360
- // ============================================================================
361
- // Cookie Types
362
- // ============================================================================
363
-
364
- /**
365
- * Cookie options interface
366
- */
367
- export interface CookieOptions {
368
- maxAge?: number
369
- expires?: Date
370
- httpOnly?: boolean
371
- secure?: boolean
372
- path?: string
373
- domain?: string
374
- sameSite?: 'strict' | 'lax' | 'none'
375
- priority?: 'low' | 'medium' | 'high'
376
- partitioned?: boolean
377
- }
378
-
379
- /**
380
- * Cookie to set - replaces `{ name: string, value: string, options: any }`
381
- */
382
- export interface CookieToSet {
383
- name: string
384
- value: string
385
- options: CookieOptions
386
- }
387
-
388
- /**
389
- * Cookie to delete - replaces `{ name: string, options: any }`
390
- */
391
- export interface CookieToDelete {
392
- name: string
393
- options: Pick<CookieOptions, 'path' | 'domain'>
394
- }
395
-
396
- // ============================================================================
397
- // SSE Types
398
- // ============================================================================
399
-
400
- /**
401
- * SSE connection info - replaces `sse?: { id: string, eventSource?: any }`
402
- */
403
- export interface SSEConnection {
404
- id: string
405
- controller?: ReadableStreamDefaultController<Uint8Array>
406
- eventSource?: unknown
407
- lastEventId?: string
408
- retryInterval?: number
409
- connectedAt?: number
410
- }
411
-
412
- // ============================================================================
413
- // Request Context Types
414
- // ============================================================================
415
-
416
- /**
417
- * Logger interface for middleware
418
- */
419
- export interface Logger {
420
- log: (message: string, ...args: unknown[]) => void
421
- info: (message: string, ...args: unknown[]) => void
422
- warn: (message: string, ...args: unknown[]) => void
423
- error: (message: string, ...args: unknown[]) => void
424
- debug: (message: string, ...args: unknown[]) => void
425
- }
426
-
427
- /**
428
- * Simple cache interface for middleware
429
- */
430
- export interface SimpleCache {
431
- get: <T = unknown>(key: string) => T | undefined
432
- set: <T = unknown>(key: string, value: T, ttl?: number) => void
433
- delete: (key: string) => boolean
434
- has: (key: string) => boolean
435
- clear: () => void
436
- }
437
-
438
- /**
439
- * Request context - replaces `context?: Record<string, any>`
440
- */
441
- export interface RequestContext {
442
- startTime?: number
443
- requestId?: string
444
- traceId?: string
445
- spanId?: string
446
- route?: string
447
- routeName?: string
448
- locale?: string
449
- timezone?: string
450
- logger?: Logger
451
- cache?: SimpleCache
452
- [key: string]: unknown
453
- }
454
-
455
- /**
456
- * Validated data - replaces `validated?: Record<string, any>`
457
- */
458
- export type ValidatedData<T = Record<string, unknown>> = T
459
-
460
- /**
461
- * Flash messages - replaces `flash?: Record<string, any>`
462
- */
463
- export interface FlashMessages {
464
- success?: string | string[]
465
- error?: string | string[]
466
- warning?: string | string[]
467
- info?: string | string[]
468
- [key: string]: string | string[] | undefined
469
- }
470
-
471
- // ============================================================================
472
- // Model Binding Types
473
- // ============================================================================
474
-
475
- /**
476
- * Bound models - replaces `models?: Record<string, any>`
477
- */
478
- export type BoundModels<T extends Record<string, unknown> = Record<string, unknown>> = T
479
-
480
- // ============================================================================
481
- // Form & Body Types
482
- // ============================================================================
483
-
484
- /**
485
- * JSON body data type - replaces `jsonBody?: any`
486
- */
487
- export type JsonBodyData<T = unknown> = T
488
-
489
- /**
490
- * Form body - replaces `formBody?: Record<string, any>`
491
- */
492
- export interface FormBody {
493
- [key: string]: string | string[] | File | File[] | undefined
494
- }
495
-
496
- /**
497
- * Validated body - replaces `validatedBody?: any`
498
- */
499
- export type ValidatedBody<T = unknown> = T
500
-
501
- // ============================================================================
502
- // Cache Types
503
- // ============================================================================
504
-
505
- /**
506
- * Cache adapter interface - replaces custom adapter with `any`
507
- */
508
- export interface CacheAdapter<T = unknown> {
509
- get: (key: string) => Promise<T | null>
510
- set: (key: string, value: T, ttl?: number) => Promise<void>
511
- del: (key: string) => Promise<void>
512
- clear?: () => Promise<void>
513
- has?: (key: string) => Promise<boolean>
514
- stats?: () => Promise<CacheStats>
515
- }
516
-
517
- /**
518
- * Cache statistics
519
- */
520
- export interface CacheStats {
521
- hits: number
522
- misses: number
523
- keys: number
524
- size?: number
525
- hitRate?: number
526
- }
527
-
528
- // ============================================================================
529
- // JWT Types
530
- // ============================================================================
531
-
532
- /**
533
- * JWT Header - replaces `header?: Record<string, any>`
534
- */
535
- export interface JwtHeader {
536
- alg: 'HS256' | 'HS384' | 'HS512' | 'RS256' | 'RS384' | 'RS512' | 'ES256' | 'ES384' | 'ES512' | 'PS256' | 'PS384' | 'PS512' | 'none'
537
- typ: 'JWT'
538
- kid?: string
539
- x5u?: string
540
- x5c?: string[]
541
- x5t?: string
542
- cty?: string
543
- crit?: string[]
544
- [key: string]: string | string[] | undefined
545
- }
546
-
547
- /**
548
- * JWT Payload - replaces index signature with `any`
549
- */
550
- export interface JwtPayload {
551
- iss?: string
552
- sub?: string
553
- aud?: string | string[]
554
- exp?: number
555
- nbf?: number
556
- iat?: number
557
- jti?: string
558
- [key: string]: string | number | boolean | string[] | undefined
559
- }
560
-
561
- // ============================================================================
562
- // Route Metadata Types
563
- // ============================================================================
564
-
565
- /**
566
- * Route metadata - replaces `meta?: Record<string, any>`
567
- */
568
- export interface RouteMetadata {
569
- description?: string
570
- summary?: string
571
- tags?: string[]
572
- deprecated?: boolean
573
- version?: string
574
- permissions?: string[]
575
- roles?: string[]
576
- rateLimit?: string
577
- cache?: {
578
- enabled: boolean
579
- ttl: number
580
- tags?: string[]
581
- }
582
- openapi?: {
583
- operationId?: string
584
- requestBody?: unknown
585
- responses?: Record<string, unknown>
586
- parameters?: unknown[]
587
- security?: unknown[]
588
- }
589
- [key: string]: unknown
590
- }
591
-
592
- // ============================================================================
593
- // Error Types
594
- // ============================================================================
595
-
596
- /**
597
- * Error metadata - replaces `metadata?: Record<string, any>`
598
- */
599
- export interface ErrorMetadata {
600
- code?: string
601
- field?: string
602
- value?: unknown
603
- constraint?: string
604
- expected?: unknown
605
- received?: unknown
606
- path?: string[]
607
- [key: string]: unknown
608
- }
609
-
610
- // ============================================================================
611
- // Middleware Types
612
- // ============================================================================
613
-
614
- /**
615
- * Middleware params - replaces `params?: Record<string, any>`
616
- */
617
- export interface MiddlewareParams {
618
- [key: string]: string | number | boolean | string[] | undefined
619
- }
620
-
621
- // ============================================================================
622
- // Degradation Types
623
- // ============================================================================
624
-
625
- /**
626
- * Static response body - replaces `body: any`
627
- */
628
- export type StaticResponseBody = string | Record<string, unknown> | unknown[]
629
-
630
- /**
631
- * Fallback handler error - replaces `error: any`
632
- */
633
- export type FallbackError = Error | { message: string, code?: string, status?: number }
634
-
635
- // ============================================================================
636
- // Input Types
637
- // ============================================================================
638
-
639
- /**
640
- * Input value - replaces various `any` in input handling
641
- */
642
- export type InputValue = string | number | boolean | null | undefined | InputValue[] | { [key: string]: InputValue }
643
-
644
- /**
645
- * Request input - replaces `all(): Record<string, any>`
646
- */
647
- export type RequestInput = Record<string, InputValue>
648
-
649
- // ============================================================================
650
- // File Types
651
- // ============================================================================
652
-
653
- /**
654
- * File info - replaces `file: (name: string) => any`
655
- */
656
- export interface FileInfo {
657
- fieldName: string
658
- originalName: string
659
- filename: string
660
- path: string
661
- size: number
662
- mimetype: string
663
- buffer: ArrayBuffer
664
- encoding?: string
665
- hash?: string
666
- }
667
-
668
- // ============================================================================
669
- // Export all types
670
- // ============================================================================
671
-
672
- export type {
673
- AuthContext as AuthContextType,
674
- CookieOptions as CookieOptionsType,
675
- MetricEntry as MetricEntryType,
676
- OAuth2Flows as OAuth2FlowsType,
677
- OAuth2Profile as OAuth2ProfileType,
678
- SessionData as SessionDataType,
679
- TraceAttributes as TraceAttributesType,
680
- User as UserType,
681
- ValidationSchema as ValidationSchemaType,
682
- WebSocketData as WebSocketDataType,
683
- }