@stacksjs/bun-router 0.0.13 → 0.0.14

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