@stacksjs/bun-router 0.0.2 → 0.0.4

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