@stacksjs/bun-router 0.0.5 → 0.0.6

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 (269) hide show
  1. package/dist/auth.d.ts +134 -0
  2. package/dist/cache/lru-cache.d.ts +139 -0
  3. package/dist/cache/middleware-memoization.d.ts +151 -0
  4. package/dist/cache/route-cache-warmer.d.ts +161 -0
  5. package/dist/cache/sqlite-cache.d.ts +209 -0
  6. package/dist/cache/streaming-cache.d.ts +132 -0
  7. package/dist/cli/colors.d.ts +15 -0
  8. package/dist/cli/index.d.ts +10 -0
  9. package/dist/cli/middleware.d.ts +31 -0
  10. package/dist/cli/openapi.d.ts +17 -0
  11. package/dist/cli/router.d.ts +15 -0
  12. package/dist/cli/routes.d.ts +29 -0
  13. package/dist/cli/utils.d.ts +74 -0
  14. package/dist/cli.d.ts +1 -1
  15. package/dist/cli.js +1 -1
  16. package/dist/config.d.ts +7 -0
  17. package/dist/container/container.d.ts +273 -0
  18. package/dist/container/contextual-binding.d.ts +240 -0
  19. package/dist/container/decorators.d.ts +141 -0
  20. package/dist/container/service-provider.d.ts +285 -0
  21. package/dist/development/hot-reload.d.ts +187 -0
  22. package/dist/development/index.d.ts +167 -0
  23. package/dist/development/performance-profiler.d.ts +217 -0
  24. package/dist/development/route-debugger.d.ts +154 -0
  25. package/dist/development/route-inspector.d.ts +211 -0
  26. package/dist/development/typescript-utilities.d.ts +209 -0
  27. package/dist/docs.d.ts +11 -0
  28. package/dist/errors/circuit-breaker.d.ts +195 -0
  29. package/dist/errors/error-handler.d.ts +88 -0
  30. package/dist/errors/error-reporting.d.ts +144 -0
  31. package/dist/errors/exceptions.d.ts +184 -0
  32. package/dist/errors/graceful-degradation.d.ts +154 -0
  33. package/dist/errors/index.d.ts +9 -0
  34. package/dist/errors/router-errors.d.ts +110 -0
  35. package/dist/file-serving/static-files.d.ts +143 -0
  36. package/dist/index.d.ts +2 -0
  37. package/dist/index.js +319 -205
  38. package/dist/middleware/auth.d.ts +63 -0
  39. package/dist/middleware/content_security_policy.d.ts +53 -0
  40. package/dist/middleware/cors.d.ts +5 -0
  41. package/dist/middleware/csrf.d.ts +7 -0
  42. package/dist/middleware/ddos_protection.d.ts +39 -0
  43. package/dist/middleware/file_security.d.ts +26 -0
  44. package/dist/middleware/file_upload.d.ts +38 -0
  45. package/dist/middleware/helmet.d.ts +54 -0
  46. package/dist/middleware/index.d.ts +44 -0
  47. package/dist/middleware/input_validation.d.ts +45 -0
  48. package/dist/middleware/json_body.d.ts +4 -0
  49. package/dist/middleware/performance_alerting.d.ts +87 -0
  50. package/dist/middleware/performance_dashboard.d.ts +87 -0
  51. package/dist/middleware/performance_monitor.d.ts +209 -0
  52. package/dist/middleware/pipeline.d.ts +131 -0
  53. package/dist/middleware/rate_limit.d.ts +36 -0
  54. package/dist/middleware/request_id.d.ts +4 -0
  55. package/dist/middleware/request_signing.d.ts +153 -0
  56. package/dist/middleware/request_tracer.d.ts +72 -0
  57. package/dist/middleware/response_cache.d.ts +97 -0
  58. package/dist/middleware/security.d.ts +69 -0
  59. package/dist/middleware/security_suite.d.ts +46 -0
  60. package/dist/middleware/session.d.ts +23 -0
  61. package/dist/model-binding/index.d.ts +2 -0
  62. package/dist/model-binding/model-middleware.d.ts +118 -0
  63. package/dist/model-binding/model-registry.d.ts +164 -0
  64. package/dist/model-binding.d.ts +185 -0
  65. package/dist/model-resolver-factory.d.ts +31 -0
  66. package/dist/observability/correlation.d.ts +187 -0
  67. package/dist/observability/health-checks.d.ts +186 -0
  68. package/dist/observability/index.d.ts +60 -0
  69. package/dist/observability/integration.d.ts +147 -0
  70. package/dist/observability/metrics.d.ts +184 -0
  71. package/dist/observability/tracing.d.ts +187 -0
  72. package/dist/optimization/bun-utilities.d.ts +224 -0
  73. package/dist/query-builder-integration.d.ts +36 -0
  74. package/dist/request/context.d.ts +34 -0
  75. package/dist/request/enhanced-request.d.ts +213 -0
  76. package/dist/request/macros.d.ts +300 -0
  77. package/dist/response/macros.d.ts +245 -0
  78. package/dist/response/response-factory.d.ts +133 -0
  79. package/dist/router/api-routes.d.ts +5 -0
  80. package/dist/router/file-based-routing.d.ts +118 -0
  81. package/dist/router/file-streaming.d.ts +5 -0
  82. package/dist/router/fluent-router.d.ts +315 -0
  83. package/dist/router/fluent-routing.d.ts +271 -0
  84. package/dist/router/group-organization.d.ts +5 -0
  85. package/dist/router/handler-resolver.d.ts +24 -0
  86. package/dist/router/http-methods.d.ts +10 -0
  87. package/dist/router/index.d.ts +113 -0
  88. package/dist/router/middleware-groups.d.ts +94 -0
  89. package/dist/router/middleware-integration.d.ts +112 -0
  90. package/dist/router/middleware.d.ts +5 -0
  91. package/dist/router/model-binding.d.ts +5 -0
  92. package/dist/router/optimized-route-matching.d.ts +6 -0
  93. package/dist/router/route-building.d.ts +5 -0
  94. package/dist/router/route-compiler.d.ts +153 -0
  95. package/dist/router/route-matching.d.ts +5 -0
  96. package/dist/router/route-trie.d.ts +114 -0
  97. package/dist/router/router.d.ts +276 -0
  98. package/dist/router/server.d.ts +5 -0
  99. package/dist/router/validation-integration.d.ts +170 -0
  100. package/dist/router/view-rendering.d.ts +5 -0
  101. package/dist/router/websocket.d.ts +5 -0
  102. package/dist/routing/route-caching.d.ts +129 -0
  103. package/dist/routing/route-throttling.d.ts +150 -0
  104. package/dist/routing/subdomain-routing.d.ts +206 -0
  105. package/dist/session/database-store.d.ts +51 -0
  106. package/dist/session/file-store.d.ts +22 -0
  107. package/dist/session/index.d.ts +106 -0
  108. package/dist/session/memory-store.d.ts +21 -0
  109. package/dist/session/redis-store.d.ts +31 -0
  110. package/dist/streaming/index.d.ts +3 -0
  111. package/dist/streaming/sse-handler.d.ts +138 -0
  112. package/dist/streaming/stream-handler.d.ts +114 -0
  113. package/dist/testing/auth-testing.d.ts +156 -0
  114. package/dist/testing/file-upload-testing.d.ts +190 -0
  115. package/dist/testing/index.d.ts +10 -0
  116. package/dist/testing/middleware-testing.d.ts +138 -0
  117. package/dist/testing/model-binding-testing.d.ts +186 -0
  118. package/dist/testing/performance-testing.d.ts +235 -0
  119. package/dist/testing/test-client.d.ts +117 -0
  120. package/dist/testing/test-request.d.ts +85 -0
  121. package/dist/testing/test-response.d.ts +90 -0
  122. package/dist/testing/types.d.ts +207 -0
  123. package/dist/testing/websocket-testing.d.ts +227 -0
  124. package/dist/types/controller-types.d.ts +208 -0
  125. package/dist/types/core.d.ts +543 -0
  126. package/dist/types/middleware-types.d.ts +227 -0
  127. package/dist/types/request-response-augmentation.d.ts +261 -0
  128. package/dist/types/route-inference.d.ts +168 -0
  129. package/dist/types.d.ts +1776 -0
  130. package/dist/url.d.ts +56 -0
  131. package/dist/utils/index.d.ts +1 -0
  132. package/dist/utils/query-preservation.d.ts +48 -0
  133. package/dist/utils.d.ts +69 -0
  134. package/dist/validation/validator.d.ts +140 -0
  135. package/dist/websocket/clustering.d.ts +185 -0
  136. package/package.json +3 -2
  137. package/src/auth.ts +469 -0
  138. package/src/cache/lru-cache.ts +457 -0
  139. package/src/cache/middleware-memoization.ts +531 -0
  140. package/src/cache/route-cache-warmer.ts +486 -0
  141. package/src/cache/sqlite-cache.ts +783 -0
  142. package/src/cache/streaming-cache.ts +572 -0
  143. package/src/cli/colors.ts +29 -0
  144. package/src/cli/index.ts +287 -0
  145. package/src/cli/middleware.ts +291 -0
  146. package/src/cli/openapi.ts +407 -0
  147. package/src/cli/router.ts +188 -0
  148. package/src/cli/routes.ts +265 -0
  149. package/src/cli/utils.ts +531 -0
  150. package/src/cli.ts +5 -0
  151. package/src/config.ts +322 -0
  152. package/src/container/container.ts +740 -0
  153. package/src/container/contextual-binding.ts +603 -0
  154. package/src/container/decorators.ts +359 -0
  155. package/src/container/service-provider.ts +596 -0
  156. package/src/development/hot-reload.ts +673 -0
  157. package/src/development/index.ts +499 -0
  158. package/src/development/performance-profiler.ts +717 -0
  159. package/src/development/route-debugger.ts +527 -0
  160. package/src/development/route-inspector.ts +749 -0
  161. package/src/development/typescript-utilities.ts +678 -0
  162. package/src/docs.ts +397 -0
  163. package/src/errors/circuit-breaker.ts +732 -0
  164. package/src/errors/error-handler.ts +569 -0
  165. package/src/errors/error-reporting.ts +672 -0
  166. package/src/errors/exceptions.ts +536 -0
  167. package/src/errors/graceful-degradation.ts +621 -0
  168. package/src/errors/index.ts +21 -0
  169. package/src/errors/router-errors.ts +632 -0
  170. package/src/file-serving/static-files.ts +581 -0
  171. package/src/index.ts +14 -0
  172. package/src/middleware/auth.ts +219 -0
  173. package/src/middleware/content_security_policy.ts +215 -0
  174. package/src/middleware/cors.ts +74 -0
  175. package/src/middleware/csrf.ts +108 -0
  176. package/src/middleware/ddos_protection.ts +255 -0
  177. package/src/middleware/file_security.ts +191 -0
  178. package/src/middleware/file_upload.ts +264 -0
  179. package/src/middleware/helmet.ts +268 -0
  180. package/src/middleware/index.ts +117 -0
  181. package/src/middleware/input_validation.ts +449 -0
  182. package/src/middleware/json_body.ts +37 -0
  183. package/src/middleware/performance_alerting.ts +538 -0
  184. package/src/middleware/performance_dashboard.ts +661 -0
  185. package/src/middleware/performance_monitor.ts +943 -0
  186. package/src/middleware/pipeline.ts +489 -0
  187. package/src/middleware/rate_limit.ts +245 -0
  188. package/src/middleware/request_id.ts +36 -0
  189. package/src/middleware/request_signing.ts +636 -0
  190. package/src/middleware/request_tracer.ts +636 -0
  191. package/src/middleware/response_cache.ts +743 -0
  192. package/src/middleware/security.ts +482 -0
  193. package/src/middleware/security_suite.ts +257 -0
  194. package/src/middleware/session.ts +91 -0
  195. package/src/model-binding/index.ts +18 -0
  196. package/src/model-binding/model-middleware.ts +425 -0
  197. package/src/model-binding/model-registry.ts +550 -0
  198. package/src/model-binding.ts +370 -0
  199. package/src/model-resolver-factory.ts +106 -0
  200. package/src/observability/correlation.ts +691 -0
  201. package/src/observability/health-checks.ts +729 -0
  202. package/src/observability/index.ts +184 -0
  203. package/src/observability/integration.ts +548 -0
  204. package/src/observability/metrics.ts +753 -0
  205. package/src/observability/tracing.ts +638 -0
  206. package/src/optimization/bun-utilities.ts +778 -0
  207. package/src/query-builder-integration.ts +137 -0
  208. package/src/request/context.ts +62 -0
  209. package/src/request/enhanced-request.ts +857 -0
  210. package/src/request/macros.ts +688 -0
  211. package/src/response/macros.ts +612 -0
  212. package/src/response/response-factory.ts +588 -0
  213. package/src/router/api-routes.ts +243 -0
  214. package/src/router/file-based-routing.ts +670 -0
  215. package/src/router/file-streaming.ts +372 -0
  216. package/src/router/fluent-router.ts +927 -0
  217. package/src/router/fluent-routing.ts +797 -0
  218. package/src/router/group-organization.ts +213 -0
  219. package/src/router/handler-resolver.ts +291 -0
  220. package/src/router/http-methods.ts +377 -0
  221. package/src/router/index.ts +185 -0
  222. package/src/router/middleware-groups.ts +222 -0
  223. package/src/router/middleware-integration.ts +399 -0
  224. package/src/router/middleware.ts +231 -0
  225. package/src/router/model-binding.ts +215 -0
  226. package/src/router/optimized-route-matching.ts +253 -0
  227. package/src/router/route-building.ts +212 -0
  228. package/src/router/route-compiler.ts +702 -0
  229. package/src/router/route-matching.ts +349 -0
  230. package/src/router/route-trie.ts +464 -0
  231. package/src/router/router.ts +1508 -0
  232. package/src/router/server.ts +406 -0
  233. package/src/router/validation-integration.ts +443 -0
  234. package/src/router/view-rendering.ts +233 -0
  235. package/src/router/websocket.ts +100 -0
  236. package/src/routing/route-caching.ts +402 -0
  237. package/src/routing/route-throttling.ts +469 -0
  238. package/src/routing/subdomain-routing.ts +492 -0
  239. package/src/session/database-store.ts +109 -0
  240. package/src/session/file-store.ts +148 -0
  241. package/src/session/index.ts +244 -0
  242. package/src/session/memory-store.ts +88 -0
  243. package/src/session/redis-store.ts +93 -0
  244. package/src/streaming/index.ts +17 -0
  245. package/src/streaming/sse-handler.ts +482 -0
  246. package/src/streaming/stream-handler.ts +552 -0
  247. package/src/testing/auth-testing.ts +446 -0
  248. package/src/testing/file-upload-testing.ts +543 -0
  249. package/src/testing/index.ts +10 -0
  250. package/src/testing/middleware-testing.ts +322 -0
  251. package/src/testing/model-binding-testing.ts +645 -0
  252. package/src/testing/performance-testing.ts +738 -0
  253. package/src/testing/test-client.ts +310 -0
  254. package/src/testing/test-request.ts +315 -0
  255. package/src/testing/test-response.ts +332 -0
  256. package/src/testing/types.ts +224 -0
  257. package/src/testing/websocket-testing.ts +590 -0
  258. package/src/types/controller-types.ts +385 -0
  259. package/src/types/core.ts +683 -0
  260. package/src/types/middleware-types.ts +419 -0
  261. package/src/types/request-response-augmentation.ts +489 -0
  262. package/src/types/route-inference.ts +357 -0
  263. package/src/types.ts +2049 -0
  264. package/src/url.ts +126 -0
  265. package/src/utils/index.ts +1 -0
  266. package/src/utils/query-preservation.ts +201 -0
  267. package/src/utils.ts +327 -0
  268. package/src/validation/validator.ts +685 -0
  269. package/src/websocket/clustering.ts +762 -0
@@ -0,0 +1,683 @@
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
+ }