@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
package/dist/types.d.ts DELETED
@@ -1,1620 +0,0 @@
1
- import type { Server } from 'bun';
2
- import type { AuthContext, AuthenticatedUser, BoundModels, CacheAdapter, CacheStats, CookieToDelete, CookieToSet, ErrorMetadata, FallbackError, FileInfo, FlashMessages, FormBody, InputValidationSchemas, InputValue, JsonBodyData, JwtHeader, JwtPayload, MetricEntry, MiddlewareParams, OAuth2Flows, OAuth2Profile, RequestContext, RequestInput, RouteMetadata, SanitizationOptions, SanitizationRule, SessionData, SessionSerializer, SessionStore, SSEConnection, StaticResponseBody, TemplateHelper, TemplateHelpers, TraceAttributes, TraceSpan, TypedServerWebSocket, User, ValidatedBody, ValidatedData, ValidationSchema, WebSocketData, } from './types/core';
3
- import type { QueryPreservationConfig } from './utils/query-preservation';
4
- import type { Router } from './router/router';
5
- export type { QueryPreservationConfig } from './utils/query-preservation';
6
- export type {
7
- AuthContext,
8
- AuthenticatedUser,
9
- BoundModels,
10
- CacheAdapter,
11
- CacheStats,
12
- CookieToDelete,
13
- CookieToSet,
14
- ErrorMetadata,
15
- FallbackError,
16
- FileInfo,
17
- FlashMessages,
18
- FormBody,
19
- InputValidationSchemas,
20
- InputValue,
21
- JsonBodyData,
22
- JwtHeader,
23
- JwtPayload,
24
- MetricEntry,
25
- MiddlewareParams,
26
- OAuth2Flows,
27
- OAuth2Profile,
28
- RequestContext,
29
- RequestInput,
30
- RouteMetadata,
31
- SanitizationOptions,
32
- SanitizationRule,
33
- SessionData,
34
- SessionSerializer,
35
- SessionStore,
36
- SSEConnection,
37
- StaticResponseBody,
38
- TemplateHelper,
39
- TemplateHelpers,
40
- TraceAttributes,
41
- TraceSpan,
42
- TypedServerWebSocket,
43
- User,
44
- ValidatedBody,
45
- ValidatedData,
46
- ValidationSchema,
47
- WebSocketData,
48
- };
49
- export declare interface Contact {
50
- name?: string
51
- email?: string
52
- url?: string
53
- }
54
- export declare interface SecurityScheme {
55
- type: 'http' | 'apiKey' | 'oauth2' | 'openIdConnect'
56
- scheme?: string
57
- bearerFormat?: string
58
- name?: string
59
- in?: 'header' | 'query' | 'cookie'
60
- flows?: OAuth2Flows
61
- }
62
- export declare interface DocsConfig {
63
- output: string
64
- groupBy: 'path' | 'method' | 'tag'
65
- includeExamples: boolean
66
- title: string
67
- description: string
68
- version: string
69
- baseUrl: string
70
- contact?: Contact
71
- security?: Record<string, SecurityScheme>
72
- }
73
- export declare interface CorsConfig {
74
- enabled?: boolean
75
- origin?: string | string[]
76
- methods?: string[]
77
- allowedHeaders?: string[]
78
- exposedHeaders?: string[]
79
- credentials?: boolean
80
- maxAge?: number
81
- preflightContinue?: boolean
82
- optionsSuccessStatus?: number
83
- privateNetworkAccess?: boolean
84
- }
85
- export declare interface RateLimitConfig {
86
- enabled?: boolean
87
- max?: number
88
- timeWindow?: number
89
- message?: string
90
- draftMode?: boolean
91
- advanced?: {
92
- tokensPerInterval?: number
93
- interval?: number
94
- burst?: number
95
- skipFailedRequests?: boolean
96
- keyGenerator?: (req: Request) => string
97
- algorithm?: 'fixed-window' | 'sliding-window' | 'token-bucket'
98
- }
99
- stores?: {
100
- type: 'memory' | 'redis'
101
- redis?: {
102
- url: string
103
- prefix?: string
104
- }
105
- }
106
- }
107
- export declare interface CompressionConfig {
108
- enabled: boolean
109
- level: number
110
- threshold: number
111
- }
112
- export declare interface StaticConfig {
113
- enabled: boolean
114
- dir: string
115
- maxAge: number
116
- }
117
- export declare interface CacheConfig {
118
- enabled: boolean
119
- type: CacheType
120
- ttl: number
121
- max?: number
122
- redis?: {
123
- url: string
124
- prefix: string
125
- maxRetries: number
126
- connectTimeout: number
127
- cluster?: {
128
- nodes: string[]
129
- options?: {
130
- scaleReads: 'master' | 'slave' | 'all'
131
- maxRedirections: number
132
- }
133
- }
134
- }
135
- customAdapter?: CacheAdapter<unknown>
136
- routeCache?: {
137
- enabled: boolean
138
- ttl: number
139
- methods: string[]
140
- excludePaths: string[]
141
- varyByHeaders: string[]
142
- varyByQuery: string[]
143
- maxSize?: number
144
- purgeConditions?: {
145
- maxAge: number
146
- maxItems: number
147
- lowMemory: boolean
148
- }
149
- }
150
- strategies?: {
151
- [key: string]: {
152
- type: CacheStrategy
153
- ttl: number
154
- staleWhileRevalidateTtl?: number
155
- }
156
- }
157
- }
158
- export declare interface PerformanceConfig {
159
- cache: CacheConfig
160
- prefetch: {
161
- enabled: boolean
162
- paths: string[]
163
- maxConcurrent: number
164
- preloadPatterns?: string[]
165
- warmupStrategy?: 'gradual' | 'aggressive'
166
- prefetchHeaders?: Record<string, string>
167
- }
168
- optimization: {
169
- minify: boolean
170
- compress: boolean
171
- treeshake: boolean
172
- lazyLoad: boolean
173
- chunkSize: number
174
- imageOptimization?: {
175
- enabled: boolean
176
- quality: number
177
- formats: ('webp' | 'avif' | 'jpeg' | 'png')[]
178
- maxWidth: number
179
- responsive: boolean
180
- }
181
- fontOptimization?: {
182
- enabled: boolean
183
- inlineSize: number
184
- preload: boolean
185
- formats: ('woff2' | 'woff')[]
186
- }
187
- cssOptimization?: {
188
- minify: boolean
189
- purge: boolean
190
- splitChunks: boolean
191
- criticalPath: boolean
192
- }
193
- }
194
- monitoring?: {
195
- enabled?: boolean
196
- sampleRate?: number
197
- metrics?: {
198
- responseTime?: boolean
199
- memoryUsage?: boolean
200
- cpuUsage?: boolean
201
- errorRate?: boolean
202
- requestRate?: boolean
203
- cacheStats?: boolean
204
- }
205
- tracing?: {
206
- enabled?: boolean
207
- sampleRate?: number
208
- serviceName?: string
209
- serviceVersion?: string
210
- environment?: string
211
- jaegerEndpoint?: string
212
- zipkinEndpoint?: string
213
- }
214
- storage?: {
215
- type?: CacheType
216
- maxEntries?: number
217
- filePath?: string
218
- customHandler?: (metrics: MetricEntry[]) => Promise<void>
219
- }
220
- alerting?: {
221
- enabled?: boolean
222
- thresholds?: {
223
- responseTime?: number
224
- errorRate?: number
225
- memoryUsage?: number
226
- }
227
- webhookUrl?: string
228
- slackWebhook?: string
229
- emailConfig?: {
230
- smtp?: {
231
- host?: string
232
- port?: number
233
- secure?: boolean
234
- auth?: {
235
- user?: string
236
- pass?: string
237
- }
238
- }
239
- to?: string[]
240
- from?: string
241
- cache: boolean
242
- queue: boolean
243
- }
244
- }
245
- profiling?: {
246
- enabled: boolean
247
- sampleRate: number
248
- includeHeapSnapshot: boolean
249
- gcStats: boolean
250
- }
251
- logging: {
252
- level: 'debug' | 'info' | 'warn' | 'error'
253
- format: 'json' | 'pretty'
254
- destination: 'console' | 'file'
255
- rotation?: {
256
- size: string
257
- interval: string
258
- maxFiles: number
259
- }
260
- }
261
- }
262
- }
263
- export declare interface LoadBalancerConfig {
264
- enabled: boolean
265
- strategy: 'round-robin' | 'least-connections' | 'ip-hash' | 'weighted-round-robin' | 'fastest-response'
266
- healthCheck: {
267
- enabled: boolean
268
- interval: number
269
- timeout: number
270
- unhealthyThreshold: number
271
- healthyThreshold: number
272
- path: string
273
- expectedStatus?: number
274
- expectedBody?: string
275
- headers?: Record<string, string>
276
- }
277
- sticky: {
278
- enabled: boolean
279
- cookieName: string
280
- ttl: number
281
- secret?: string
282
- path?: string
283
- domain?: string
284
- }
285
- retries: {
286
- attempts: number
287
- timeout: number
288
- codes: number[]
289
- backoff?: {
290
- type: 'fixed' | 'exponential' | 'fibonacci'
291
- initialDelay: number
292
- maxDelay: number
293
- factor: number
294
- }
295
- }
296
- nodes?: {
297
- [key: string]: {
298
- url: string
299
- weight?: number
300
- backup?: boolean
301
- maxFails?: number
302
- failTimeout?: number
303
- }
304
- }
305
- }
306
- export declare interface SecurityConfig {
307
- schemes: Record<string, SecurityScheme>
308
- rateLimit: RateLimitConfig & {
309
- advanced?: {
310
- tokensPerInterval: number
311
- interval: number
312
- burst?: number
313
- skipFailedRequests?: boolean
314
- keyGenerator?: (req: Request) => string
315
- }
316
- stores?: {
317
- type: 'memory' | 'redis'
318
- redis?: {
319
- url: string
320
- prefix: string
321
- }
322
- }
323
- }
324
- cors: CorsConfig & {
325
- preflightContinue?: boolean
326
- optionsSuccessStatus?: number
327
- privateNetworkAccess?: boolean
328
- exposedHeaders?: string[]
329
- }
330
- csrf: {
331
- enabled: boolean
332
- secret: string
333
- cookie: {
334
- name: string
335
- options: {
336
- httpOnly: boolean
337
- secure: boolean
338
- sameSite: 'strict' | 'lax' | 'none'
339
- }
340
- }
341
- ignoreMethods?: string[]
342
- ignorePaths?: string[]
343
- tokenLength?: number
344
- }
345
- helmet: {
346
- enabled: boolean
347
- contentSecurityPolicy: boolean | {
348
- directives: Record<string, string[]>
349
- reportOnly?: boolean
350
- reportUri?: string
351
- upgradeInsecureRequests?: boolean
352
- blockAllMixedContent?: boolean
353
- }
354
- crossOriginEmbedderPolicy?: boolean | {
355
- policy?: 'require-corp' | 'credentialless'
356
- }
357
- crossOriginOpenerPolicy?: boolean | {
358
- policy?: 'same-origin' | 'same-origin-allow-popups' | 'unsafe-none'
359
- }
360
- crossOriginResourcePolicy?: boolean | {
361
- policy?: 'same-site' | 'same-origin' | 'cross-origin'
362
- }
363
- dnsPrefetchControl?: boolean | {
364
- allow?: boolean
365
- }
366
- xssFilter: boolean | {
367
- setOnOldIE?: boolean
368
- }
369
- noSniff: boolean
370
- frameOptions: 'DENY' | 'SAMEORIGIN'
371
- hidePoweredBy: boolean
372
- hsts?: {
373
- maxAge: number
374
- includeSubDomains: boolean
375
- preload: boolean
376
- }
377
- referrerPolicy?: string | {
378
- policy?: string | string[]
379
- }
380
- expectCt?: {
381
- enforce: boolean
382
- maxAge: number
383
- reportUri?: string
384
- }
385
- ieNoOpen?: boolean
386
- originAgentCluster?: boolean
387
- permittedCrossDomainPolicies?: boolean | {
388
- permittedPolicies?: 'none' | 'master-only' | 'by-content-type' | 'all'
389
- }
390
- }
391
- ddos?: {
392
- enabled?: boolean
393
- maxRequestsPerSecond?: number
394
- maxRequestsPerMinute?: number
395
- maxRequestsPerHour?: number
396
- burstLimit?: number
397
- windowSize?: number
398
- blockDuration?: number
399
- whitelistedIPs?: string[]
400
- blacklistedIPs?: string[]
401
- trustProxy?: boolean
402
- skipSuccessfulRequests?: boolean
403
- skipFailedRequests?: boolean
404
- keyGenerator?: (req: Request) => string
405
- store?: Extract<CacheType, 'memory' | 'redis'>
406
- redis?: {
407
- url: string
408
- prefix?: string
409
- }
410
- }
411
- inputValidation?: {
412
- enabled?: boolean
413
- sanitizeByDefault?: boolean
414
- strictMode?: boolean
415
- allowUnknownFields?: boolean
416
- maxDepth?: number
417
- schemas?: InputValidationSchemas
418
- }
419
- attackPrevention?: {
420
- enabled?: boolean
421
- sqlInjection?: boolean
422
- xss?: boolean
423
- pathTraversal?: boolean
424
- commandInjection?: boolean
425
- ldapInjection?: boolean
426
- xxe?: boolean
427
- customPatterns?: {
428
- name: string
429
- pattern: RegExp
430
- action: 'block' | 'log' | 'sanitize'
431
- }[]
432
- }
433
- requestFiltering?: {
434
- enabled?: boolean
435
- blockSuspiciousPatterns?: boolean
436
- maxRequestsPerMinute?: number
437
- blockUserAgents?: string[]
438
- allowedMethods?: string[]
439
- requireUserAgent?: boolean
440
- maxBodySize?: number
441
- maxUrlLength?: number
442
- maxHeaderSize?: number
443
- allowedContentTypes?: string[]
444
- }
445
- ipFiltering?: {
446
- enabled?: boolean
447
- whitelist?: string[]
448
- blacklist?: string[]
449
- blockPrivateIPs?: boolean
450
- blockCloudProviders?: boolean
451
- geoBlocking?: {
452
- enabled?: boolean
453
- allowedCountries?: string[]
454
- blockedCountries?: string[]
455
- }
456
- }
457
- responseSecurity?: {
458
- enabled?: boolean
459
- removeServerHeaders?: boolean
460
- addSecurityHeaders?: boolean
461
- sanitizeErrors?: boolean
462
- preventInfoDisclosure?: boolean
463
- }
464
- auth: {
465
- jwt: {
466
- secret: string
467
- expiresIn: string
468
- algorithm: 'HS256' | 'HS384' | 'HS512' | 'RS256'
469
- issuer?: string
470
- audience?: string
471
- refreshToken?: {
472
- enabled: boolean
473
- expiresIn: string
474
- renewBeforeExpiry?: number
475
- }
476
- rotation?: {
477
- enabled: boolean
478
- interval: number
479
- maxAge: number
480
- }
481
- }
482
- session: {
483
- enabled: boolean
484
- secret: string
485
- name: string
486
- resave: boolean
487
- rolling: boolean
488
- saveUninitialized: boolean
489
- cookie: {
490
- maxAge: number
491
- secure: boolean
492
- httpOnly: boolean
493
- sameSite: 'strict' | 'lax' | 'none'
494
- domain?: string
495
- path?: string
496
- }
497
- store?: {
498
- type: CacheType
499
- redis?: {
500
- url: string
501
- prefix: string
502
- ttl?: number
503
- scanCount?: number
504
- serializer?: SessionSerializer
505
- }
506
- custom?: SessionStore
507
- }
508
- }
509
- oauth2?: {
510
- enabled: boolean
511
- providers: {
512
- [key: string]: {
513
- clientId: string
514
- clientSecret: string
515
- callbackURL: string
516
- scope: string[]
517
- authorizationURL?: string
518
- tokenURL?: string
519
- profileURL?: string
520
- validateProfile?: (profile: OAuth2Profile) => Promise<boolean>
521
- }
522
- }
523
- }
524
- }
525
- encryption?: {
526
- enabled: boolean
527
- algorithm: string
528
- key: string
529
- iv?: string
530
- encoding: 'hex' | 'base64'
531
- }
532
- sanitization?: {
533
- enabled: boolean
534
- rules: {
535
- [key: string]: {
536
- type: 'escape' | 'strip' | 'validate'
537
- options?: SanitizationOptions
538
- }
539
- }
540
- }
541
- }
542
- export declare interface ServerConfig {
543
- port: number
544
- hostname: string
545
- development: boolean
546
- cors: CorsConfig
547
- rateLimit: RateLimitConfig
548
- compression: CompressionConfig
549
- static: StaticConfig
550
- performance: PerformanceConfig
551
- loadBalancer?: LoadBalancerConfig
552
- security: SecurityConfig
553
- cluster: {
554
- enabled: boolean
555
- workers: number | 'auto'
556
- sticky: boolean
557
- strategy?: 'rr' | 'lc'
558
- maxMemory?: number
559
- restartOnMemory?: boolean
560
- ipcTimeout?: number
561
- }
562
- gracefulShutdown: {
563
- enabled: boolean
564
- timeout: number
565
- signals: string[]
566
- forceTimeout: number
567
- preShutdown?: () => Promise<void>
568
- drain?: {
569
- enabled: boolean
570
- timeout: number
571
- waitForStreams: boolean
572
- }
573
- }
574
- middleware: {
575
- errorHandler?: (error: Error, req: Request) => Promise<Response>
576
- notFound?: (req: Request) => Promise<Response>
577
- timeout?: number
578
- order?: string[]
579
- global?: MiddlewareHandler[]
580
- }
581
- hooks: {
582
- onStart?: () => Promise<void>
583
- onStop?: () => Promise<void>
584
- onRequest?: (req: Request) => Promise<Request | Response>
585
- onResponse?: (res: Response) => Promise<Response>
586
- onError?: (error: Error) => Promise<void>
587
- onMetric?: (metric: { name: string, value: number, tags?: Record<string, string> }) => Promise<void>
588
- onTrace?: (span: TraceSpan) => Promise<void>
589
- }
590
- experimental?: {
591
- http3: boolean
592
- webTransport: boolean
593
- earlyHints: boolean
594
- webSocket: {
595
- enabled: boolean
596
- compression?: boolean
597
- maxPayload?: number
598
- }
599
- }
600
- }
601
- export declare interface ViewEngineConfig {
602
- viewsPath: string
603
- extensions: string[]
604
- defaultLayout?: string
605
- cache: boolean
606
- engine: TemplateEngine
607
- customRenderer?: (template: string, data: Record<string, any>, options: ViewRenderOptions) => Promise<string>
608
- minify?: {
609
- enabled: boolean
610
- options?: {
611
- removeComments?: boolean
612
- collapseWhitespace?: boolean
613
- conservativeCollapse?: boolean
614
- minifyJS?: boolean
615
- minifyCSS?: boolean
616
- }
617
- }
618
- helpers?: TemplateHelpers
619
- }
620
- export declare interface ViewRenderOptions {
621
- layout?: string
622
- partials?: Record<string, string>
623
- components?: Record<string, string>
624
- helpers?: TemplateHelpers
625
- sections?: Record<string, string>
626
- }
627
- export declare interface RouterConfig {
628
- verbose: boolean
629
- routesPath?: string
630
- apiRoutesPath?: string
631
- webRoutesPath?: string
632
- apiPrefix?: string
633
- webPrefix?: string
634
- actionsPath?: string
635
- controllersPath?: string
636
- defaultMiddleware?: {
637
- api?: (string | MiddlewareHandler)[]
638
- web?: (string | MiddlewareHandler)[]
639
- }
640
- views?: ViewEngineConfig
641
- docs?: DocsConfig
642
- server?: ServerConfig
643
- queryPreservation?: QueryPreservationConfig
644
- }
645
- export declare interface RouteParams {
646
-
647
- }
648
- /**
649
- * Cookie map interface for working with cookies
650
- */
651
- export declare interface CookieMap {
652
- get: (name: string) => string | undefined
653
- set: (name: string, value: string, options?: CookieOptions) => void
654
- delete: (name: string, options?: Pick<CookieOptions, 'path' | 'domain'>) => void
655
- getAll: () => Record<string, string>
656
- }
657
- /**
658
- * Cookie options interface
659
- */
660
- export declare interface CookieOptions {
661
- maxAge?: number
662
- expires?: Date
663
- httpOnly?: boolean
664
- secure?: boolean
665
- path?: string
666
- domain?: string
667
- sameSite?: 'strict' | 'lax' | 'none'
668
- }
669
- /**
670
- * Cookie accessor interface with utility methods
671
- */
672
- export declare interface CookieAccessor {
673
- get: (name: string) => string | undefined
674
- set: (name: string, value: string, options?: CookieOptions) => void
675
- delete: (name: string, options?: CookieOptions) => void
676
- getAll: () => Record<string, string>
677
- }
678
- export declare interface EnhancedRequest extends Request, Omit<RequestMacroMethods, 'ip' | 'cookies' | 'route'> {
679
- params: Record<string, string>
680
- query: Record<string, string | string[]>
681
- jsonBody?: Record<string, unknown>
682
- formBody?: FormBody
683
- files?: UploadedFile[]
684
- session?: SessionData
685
- user?: User
686
- context?: RequestContext
687
- validated?: ValidatedData
688
- models?: BoundModels
689
- modelErrors?: Record<string, string>
690
- auth?: AuthContext
691
- rateLimitRemaining?: number
692
- requestId?: string
693
- ip?: string
694
- cookies?: CookieAccessor
695
- flash?: FlashMessages
696
- csrfToken?: string
697
- startTime?: number
698
- traceId?: string
699
- spanId?: string
700
- nonce?: string
701
- validatedBody?: ValidatedBody
702
- _cookiesToSet?: CookieToSet[]
703
- _cookiesToDelete?: CookieToDelete[]
704
- sse?: SSEConnection
705
- route?: Route
706
- }
707
- export declare interface UploadedFile {
708
- fieldName: string
709
- originalName: string
710
- filename: string
711
- path: string
712
- size: number
713
- mimetype: string
714
- buffer: ArrayBuffer
715
- }
716
- /**
717
- * Interface for handling route actions.
718
- * All action handlers must implement this interface.
719
- */
720
- export declare interface ActionHandlerClass {
721
- handle: (request: EnhancedRequest) => Promise<Response>
722
- }
723
- /**
724
- * Action class constructor with typed handle method
725
- */
726
- export declare interface TypedActionHandlerClass<TPath extends string = string> {
727
- handle: (request: EnhancedRequest & { params: ExtractRouteParams<TPath> }) => Promise<Response>
728
- }
729
- export declare interface Middleware {
730
- handle: MiddlewareHandler
731
- }
732
- /**
733
- * Strict middleware configuration with narrow types
734
- */
735
- export declare interface StrictMiddlewareConfig {
736
- name: BuiltInMiddleware
737
- enabled: boolean
738
- priority: number
739
- timing: MiddlewareTiming
740
- params?: Record<string, string | number | boolean>
741
- }
742
- /**
743
- * Conditional middleware with narrow type constraints
744
- */
745
- export declare interface ConditionalMiddleware<T extends BuiltInMiddleware = BuiltInMiddleware> {
746
- name: T
747
- condition: (req: EnhancedRequest) => boolean
748
- handler: MiddlewareHandler
749
- priority?: number
750
- }
751
- /**
752
- * Middleware group configuration with strict typing
753
- */
754
- export declare interface MiddlewareGroup {
755
- name: string
756
- middleware: (BuiltInMiddleware | MiddlewareWithParams<BuiltInMiddleware>)[]
757
- priority: number
758
- description?: string
759
- }
760
- /**
761
- * Throttle middleware parameters with narrow types
762
- */
763
- export declare interface ThrottleMiddlewareParams {
764
- pattern: ThrottlePattern
765
- name?: string
766
- keyGenerator?: (req: EnhancedRequest) => string
767
- skipIf?: (req: EnhancedRequest) => boolean
768
- }
769
- /**
770
- * CORS middleware configuration with strict options
771
- */
772
- export declare interface CorsMiddlewareConfig {
773
- origin: string | string[] | boolean | ((origin: string) => boolean)
774
- methods: HTTPMethod[]
775
- allowedHeaders: string[]
776
- exposedHeaders?: string[]
777
- credentials: boolean
778
- maxAge: number
779
- preflightContinue: boolean
780
- optionsSuccessStatus: ResponseStatus
781
- }
782
- /**
783
- * Auth middleware configuration with narrow types
784
- */
785
- export declare interface AuthMiddlewareConfig {
786
- type: 'jwt' | 'session' | 'apikey' | 'basic' | 'bearer'
787
- required: boolean
788
- realm?: string
789
- validateUser?: (user: User) => boolean
790
- onUnauthorized?: (req: EnhancedRequest) => Response
791
- }
792
- export declare interface RouteGroup {
793
- prefix?: string
794
- middleware?: (string | MiddlewareHandler)[]
795
- }
796
- export declare interface Route {
797
- path: string
798
- handler: ActionHandler
799
- method: string
800
- middleware: MiddlewareHandler[]
801
- type?: 'api' | 'web'
802
- name?: string
803
- constraints?: Record<string, string> | ((params: Record<string, string>) => boolean)[]
804
- domain?: string
805
- params?: Record<string, string>
806
- pattern?: {
807
- exec: (url: URL) => PatternMatchResult | null
808
- }
809
- }
810
- /**
811
- * WebSocket handler configuration
812
- */
813
- export declare interface WebSocketConfig<T extends WebSocketData = WebSocketData> {
814
- open?: (ws: TypedServerWebSocket<T>) => void | Promise<void>
815
- message: (ws: TypedServerWebSocket<T>, message: string | Uint8Array | ArrayBuffer) => void | Promise<void>
816
- close?: (ws: TypedServerWebSocket<T>, code: number, reason: string) => void | Promise<void>
817
- ping?: (ws: TypedServerWebSocket<T>, data: Uint8Array) => void | Promise<void>
818
- pong?: (ws: TypedServerWebSocket<T>, data: Uint8Array) => void | Promise<void>
819
- drain?: (ws: TypedServerWebSocket<T>) => void | Promise<void>
820
- error?: (ws: TypedServerWebSocket<T>, error: Error) => void | Promise<void>
821
- maxPayloadLength?: number
822
- backpressureLimit?: number
823
- closeOnBackpressureLimit?: boolean
824
- idleTimeout?: number
825
- perMessageDeflate?: boolean | {
826
- compress?: boolean | Compressor
827
- decompress?: boolean | Compressor
828
- }
829
- sendPings?: boolean
830
- publishToSelf?: boolean
831
- }
832
- export declare interface ServerOptions<T extends WebSocketData = WebSocketData> extends Partial<Omit<Server<T>, 'websocket'>> {
833
- websocket?: WebSocketConfig<T>
834
- }
835
- /**
836
- * Type definition for route configuration with strict typing.
837
- */
838
- export declare interface RouteDefinition<TPath extends string = string, TMethod extends HTTPMethod = HTTPMethod, THandler extends ActionHandler = ActionHandler> {
839
- path: TPath
840
- method: TMethod
841
- handler: THandler
842
- middleware?: (BuiltInMiddleware | MiddlewareWithParams<BuiltInMiddleware> | MiddlewareHandler)[]
843
- type?: 'api' | 'web'
844
- name?: string
845
- constraints?: {
846
- [K in keyof ExtractRouteParams<TPath>]: RouteConstraint
847
- }
848
- meta?: RouteMetadata
849
- cache?: {
850
- enabled: boolean
851
- ttl: number
852
- tags?: string[]
853
- strategy?: CacheStrategy
854
- }
855
- throttle?: ThrottlePattern | ThrottleMiddlewareParams
856
- }
857
- /**
858
- * Strongly typed route method signatures
859
- */
860
- export declare interface TypedRouteHandler<TPath extends string> {
861
- (req: EnhancedRequest & { params: ExtractRouteParams<TPath> }): Response | Promise<Response>
862
- }
863
- /**
864
- * Strongly typed route definition for specific HTTP methods
865
- */
866
- export declare interface GetRoute<TPath extends string> extends RouteDefinition<TPath, 'GET'> {
867
- method: 'GET'
868
- handler: TypedRouteHandler<TPath> | ActionHandler
869
- }
870
- export declare interface PostRoute<TPath extends string> extends RouteDefinition<TPath, 'POST'> {
871
- method: 'POST'
872
- handler: TypedRouteHandler<TPath> | ActionHandler
873
- }
874
- export declare interface PutRoute<TPath extends string> extends RouteDefinition<TPath, 'PUT'> {
875
- method: 'PUT'
876
- handler: TypedRouteHandler<TPath> | ActionHandler
877
- }
878
- export declare interface DeleteRoute<TPath extends string> extends RouteDefinition<TPath, 'DELETE'> {
879
- method: 'DELETE'
880
- handler: TypedRouteHandler<TPath> | ActionHandler
881
- }
882
- export declare interface PatchRoute<TPath extends string> extends RouteDefinition<TPath, 'PATCH'> {
883
- method: 'PATCH'
884
- handler: TypedRouteHandler<TPath> | ActionHandler
885
- }
886
- /**
887
- * Route validation helpers
888
- */
889
- export declare interface RouteValidation<TPath extends string> {
890
- path: TPath
891
- params: ExtractRouteParams<TPath>
892
- validate: (req: EnhancedRequest) => req is EnhancedRequest & { params: ExtractRouteParams<TPath> }
893
- }
894
- /**
895
- * Server-Sent Events configuration
896
- */
897
- export declare interface SSEConfig {
898
- retryInterval?: number
899
- keepAlive?: number
900
- compression?: StreamingCompression
901
- maxConnections?: number
902
- heartbeatInterval?: number
903
- headers?: Record<string, string>
904
- enableHeartbeat?: boolean
905
- connectionTimeout?: number
906
- retryDelay?: number
907
- }
908
- /**
909
- * SSE Event data structure with strict typing
910
- */
911
- export declare interface SSEEvent<T = unknown> {
912
- data: T
913
- event?: string
914
- id?: string | number
915
- retry?: number
916
- comment?: string
917
- }
918
- /**
919
- * Direct streaming configuration
920
- */
921
- export declare interface DirectStreamConfig {
922
- headers?: Record<string, string>
923
- status?: ResponseStatus
924
- compression?: StreamingCompression
925
- format?: StreamingFormat
926
- bufferSize?: number
927
- delimiter?: string
928
- contentType?: ContentType
929
- enableCompression?: boolean
930
- compressionType?: StreamingCompression
931
- }
932
- /**
933
- * Buffered streaming configuration
934
- */
935
- export declare interface BufferedStreamConfig extends DirectStreamConfig {
936
- highWaterMark?: number
937
- maxBuffer?: number
938
- flushInterval?: number
939
- autoFlush?: boolean
940
- contentType?: ContentType
941
- }
942
- /**
943
- * File streaming configuration with strict types
944
- */
945
- export declare interface FileStreamConfig {
946
- headers?: Record<string, string>
947
- status?: ResponseStatus
948
- mimeType?: AllowedMimeType
949
- disposition?: 'inline' | 'attachment'
950
- filename?: string
951
- maxAge?: number
952
- etag?: boolean
953
- lastModified?: boolean
954
- compression?: StreamingCompression
955
- }
956
- /**
957
- * Range request configuration for file streaming
958
- */
959
- export declare interface RangeStreamConfig extends FileStreamConfig {
960
- unit?: 'bytes'
961
- maxRanges?: number
962
- enableMultipart?: boolean
963
- }
964
- /**
965
- * Transform stream configuration
966
- */
967
- export declare interface TransformStreamConfig<TInput = any, TOutput = any> {
968
- transform: (chunk: TInput) => TOutput | Promise<TOutput>
969
- flush?: () => TOutput[] | Promise<TOutput[]>
970
- objectMode?: boolean
971
- highWaterMark?: number
972
- format?: StreamingFormat
973
- headers?: Record<string, string>
974
- }
975
- /**
976
- * Streaming response writer interfaces
977
- */
978
- export declare interface StreamWriter<T = any> {
979
- write: (chunk: T) => void | Promise<void>
980
- end: () => void | Promise<void>
981
- close: () => void
982
- }
983
- export declare interface BufferedStreamWriterGeneric<T = any> extends StreamWriter<T> {
984
- flush: () => void | Promise<void>
985
- cork: () => void
986
- uncork: () => void
987
- }
988
- /**
989
- * Model binding configuration with strict types
990
- */
991
- export declare interface ModelBinding<T = any> {
992
- name: string
993
- model: string
994
- parameter: string
995
- required?: boolean
996
- as?: string
997
- resolver: ModelResolver<T>
998
- cache?: {
999
- enabled: boolean
1000
- ttl: number
1001
- key?: (params: Record<string, string>) => string
1002
- }
1003
- validation?: {
1004
- required?: boolean
1005
- validator?: (model: T) => boolean | Promise<boolean>
1006
- }
1007
- errorHandler?: (error: Error, params: Record<string, string>) => Response
1008
- }
1009
- /**
1010
- * Model registry interface
1011
- */
1012
- export declare interface ModelRegistry {
1013
- register: <T>(binding: ModelBinding<T>) => void
1014
- resolve: <T>(name: string, params: Record<string, string>, req: EnhancedRequest) => Promise<T | null>
1015
- has: (name: string) => boolean
1016
- clear: () => void
1017
- getAll: () => ModelBinding[]
1018
- }
1019
- /**
1020
- * Model binding middleware configuration
1021
- */
1022
- export declare interface ModelBindingConfig {
1023
- parameterName: string
1024
- modelName: string
1025
- required?: boolean
1026
- cacheKey?: (params: Record<string, string>) => string
1027
- }
1028
- /**
1029
- * Resource route configuration with model binding
1030
- */
1031
- export declare interface ResourceConfig {
1032
- controller: string
1033
- only?: ('index' | 'show' | 'create' | 'store' | 'edit' | 'update' | 'destroy')[]
1034
- except?: ('index' | 'show' | 'create' | 'store' | 'edit' | 'update' | 'destroy')[]
1035
- middleware?: (BuiltInMiddleware | MiddlewareWithParams<BuiltInMiddleware>)[]
1036
- bindings?: Record<string, string>
1037
- names?: Partial<Record<'index' | 'show' | 'create' | 'store' | 'edit' | 'update' | 'destroy', string>>
1038
- }
1039
- /**
1040
- * Stream route handler with typed path parameters
1041
- */
1042
- export declare interface StreamRouteHandler<TPath extends string = string> {
1043
- (req: EnhancedRequest & { params: ExtractRouteParams<TPath> }, writer: StreamWriter): Promise<void> | void
1044
- }
1045
- /**
1046
- * SSE route handler with typed path parameters
1047
- */
1048
- export declare interface SSERouteHandler<TPath extends string = string> {
1049
- (req: EnhancedRequest & { params: ExtractRouteParams<TPath> }): SSEGenerator | AsyncGenerator<SSEEvent, void, unknown>
1050
- }
1051
- /**
1052
- * Route matching result
1053
- */
1054
- export declare interface MatchResult {
1055
- route: Route
1056
- params: Record<string, string>
1057
- }
1058
- /**
1059
- * URL pattern match result
1060
- */
1061
- export declare interface PatternMatchResult {
1062
- pathname: {
1063
- groups: Record<string, string>
1064
- }
1065
- }
1066
- /**
1067
- * Streaming response options
1068
- */
1069
- export declare interface StreamingOptions {
1070
- headers?: Record<string, string>
1071
- status?: number
1072
- }
1073
- /**
1074
- * SSE (Server-Sent Events) data structure
1075
- */
1076
- export declare interface SSEData {
1077
- data: any
1078
- event?: string
1079
- id?: string
1080
- retry?: number
1081
- }
1082
- /**
1083
- * Direct streaming writer interface
1084
- */
1085
- export declare interface DirectStreamWriter {
1086
- write: (chunk: string | Uint8Array) => void
1087
- close: () => void
1088
- }
1089
- /**
1090
- * Buffered streaming writer interface
1091
- */
1092
- export declare interface BufferedStreamWriter {
1093
- write: (chunk: string | Uint8Array) => void
1094
- flush: () => void
1095
- end: () => void
1096
- }
1097
- /**
1098
- * Buffered streaming options
1099
- */
1100
- export declare interface BufferedStreamOptions {
1101
- highWaterMark?: number
1102
- asUint8Array?: boolean
1103
- }
1104
- /**
1105
- * Advanced Error Handling Types
1106
- */
1107
- export declare interface ErrorContext {
1108
- requestId?: string
1109
- userId?: string | number
1110
- traceId?: string
1111
- spanId?: string
1112
- route?: string
1113
- method?: string
1114
- url?: string
1115
- userAgent?: string
1116
- ip?: string
1117
- timestamp?: Date
1118
- metadata?: ErrorMetadata
1119
- }
1120
- export declare interface ErrorReportingConfig {
1121
- enabled: boolean
1122
- service: 'sentry' | 'bugsnag' | 'custom'
1123
- dsn?: string
1124
- apiKey?: string
1125
- environment?: string
1126
- release?: string
1127
- sampleRate?: number
1128
- beforeSend?: (error: Error, context: ErrorContext) => Error | null
1129
- filters?: {
1130
- ignoreErrors?: (string | RegExp)[]
1131
- ignoreCodes?: string[]
1132
- ignoreUrls?: (string | RegExp)[]
1133
- allowUrls?: (string | RegExp)[]
1134
- }
1135
- tags?: Record<string, string>
1136
- user?: {
1137
- id?: string
1138
- email?: string
1139
- username?: string
1140
- }
1141
- extra?: Record<string, unknown>
1142
- breadcrumbs?: {
1143
- enabled: boolean
1144
- maxBreadcrumbs: number
1145
- }
1146
- performance?: {
1147
- enabled: boolean
1148
- tracesSampleRate: number
1149
- }
1150
- }
1151
- export declare interface CircuitBreakerConfig {
1152
- name: string
1153
- failureThreshold: number
1154
- recoveryTimeout: number
1155
- timeout: number
1156
- monitoringPeriod: number
1157
- minimumRequests: number
1158
- errorThresholdPercentage: number
1159
- halfOpenMaxCalls: number
1160
- resetTimeout: number
1161
- onStateChange?: (state: 'CLOSED' | 'OPEN' | 'HALF_OPEN', name: string) => void
1162
- onFailure?: (error: Error, name: string) => void
1163
- onSuccess?: (name: string) => void
1164
- shouldTripOnError?: (error: Error) => boolean
1165
- }
1166
- export declare interface DegradationConfig {
1167
- enabled: boolean
1168
- fallbackStrategies: {
1169
- [serviceName: string]: {
1170
- type: 'cache' | 'static' | 'simplified' | 'redirect' | 'custom'
1171
- priority: number
1172
- timeout: number
1173
- retries: number
1174
- backoff: {
1175
- type: 'fixed' | 'exponential'
1176
- delay: number
1177
- maxDelay?: number
1178
- }
1179
- fallbackHandler?: (error: FallbackError, context: ErrorContext) => Promise<Response>
1180
- cacheConfig?: {
1181
- key: string
1182
- ttl: number
1183
- staleWhileRevalidate: boolean
1184
- }
1185
- staticResponse?: {
1186
- status: number
1187
- body: StaticResponseBody
1188
- headers?: Record<string, string>
1189
- }
1190
- redirectConfig?: {
1191
- url: string
1192
- permanent: boolean
1193
- }
1194
- }
1195
- }
1196
- healthChecks: {
1197
- [serviceName: string]: {
1198
- enabled: boolean
1199
- endpoint: string
1200
- interval: number
1201
- timeout: number
1202
- retries: number
1203
- expectedStatus: number[]
1204
- expectedBody?: string | RegExp
1205
- headers?: Record<string, string>
1206
- onHealthy?: () => void
1207
- onUnhealthy?: (error: Error) => void
1208
- }
1209
- }
1210
- monitoring: {
1211
- enabled: boolean
1212
- alertThresholds: {
1213
- errorRate: number
1214
- responseTime: number
1215
- availability: number
1216
- }
1217
- }
1218
- }
1219
- /**
1220
- * Request/Response Enhancement Types
1221
- */
1222
- export declare interface RequestMacroMethods {
1223
- wantsJson: () => boolean
1224
- wantsHtml: () => boolean
1225
- wantsXml: () => boolean
1226
- expectsJson: () => boolean
1227
- isAjax: () => boolean
1228
- isPjax: () => boolean
1229
- isMobile: () => boolean
1230
- isBot: () => boolean
1231
- isSecure: () => boolean
1232
- ip: () => string
1233
- ips: () => string[]
1234
- userAgent: () => string
1235
- referer: () => string | null
1236
- bearerToken: () => string | null
1237
- basicAuth: () => { username: string, password: string } | null
1238
- hasHeader: (name: string) => boolean
1239
- header: (name: string, defaultValue?: string) => string | null
1240
- allHeaders: () => Record<string, string>
1241
- input: <T = InputValue>(key: string, defaultValue?: T) => T
1242
- all: () => RequestInput
1243
- only: (keys: string[]) => RequestInput
1244
- except: (keys: string[]) => RequestInput
1245
- has: (key: string) => boolean
1246
- hasAny: (keys: string[]) => boolean
1247
- missing: (key: string) => boolean
1248
- filled: (key: string) => boolean
1249
- getQuery: <T = InputValue>(key?: string, defaultValue?: T) => T
1250
- param: <T = InputValue>(key: string, defaultValue?: T) => T
1251
- cookie: (name: string, defaultValue?: string) => string | null
1252
- cookies: () => Record<string, string>
1253
- file: (name: string) => FileInfo | null
1254
- hasFile: (name: string) => boolean
1255
- path: () => string
1256
- fullUrl: () => string
1257
- root: () => string
1258
- is: (pattern: string) => boolean
1259
- route: () => string | null
1260
- fingerprint: () => string
1261
- signature: (secret: string) => string
1262
- merge: (data: RequestInput) => void
1263
- replace: (data: RequestInput) => void
1264
- age: () => number
1265
- isFromTrustedProxy: (trustedProxies?: string[]) => boolean
1266
- contentLength: () => number
1267
- contentType: () => string | null
1268
- isContentType: (type: string) => boolean
1269
- }
1270
- /**
1271
- * Extreme narrow types for Laravel-style methods with template literal patterns
1272
- */
1273
- export declare interface EnhancedLaravelStreamingMethods {
1274
- stream: <T extends string | Uint8Array = string>(
1275
- callback: StreamCallbackGenerator<T>,
1276
- status?: ResponseStatus,
1277
- headers?: Record<string, string>
1278
- ) => Response
1279
- streamJson: <T, K extends string = string>(
1280
- data: Record<K, Iterable<T> | AsyncIterable<T>>,
1281
- status?: ResponseStatus,
1282
- headers?: Record<string, string>
1283
- ) => Response
1284
- eventStream: <T = unknown>(
1285
- callback: SSEEventGenerator<T>,
1286
- headers?: Record<string, string>
1287
- ) => Response
1288
- streamDownload: <T extends string | Uint8Array = string>(
1289
- callback: StreamCallbackGenerator<T>,
1290
- filename: `${string}.${string}`, // Must have extension
1291
- headers?: Record<string, string>
1292
- ) => Response
1293
- }
1294
- /**
1295
- * Enhanced model binding with strict key typing
1296
- */
1297
- export declare interface EnhancedLaravelModelBindingMethods {
1298
- model: <T, K extends string>(
1299
- key: K,
1300
- modelClass: string | ((value: string) => Promise<T | null>),
1301
- callback?: (model: T | null) => Response | null
1302
- ) => Router & { [P in K]: T }
1303
- scopedBindings: <Parent extends string, Child extends string>(
1304
- bindings: Record<Child, Parent>
1305
- ) => MiddlewareHandler
1306
- }
1307
- export type RouterOptions = Partial<RouterConfig>
1308
- export type RouteHandler = (req: EnhancedRequest) => Response | Promise<Response>
1309
- /**
1310
- * Action handler path with strict pattern validation
1311
- */
1312
- export type ActionPath = `Actions/${string}Action` | `actions/${string}Action` | `${string}Controller@${string}`
1313
- /**
1314
- * Strongly typed action handler with better type safety
1315
- */
1316
- export type ActionHandler<TPath extends string = string> = | ActionPath
1317
- | TypedRouteHandler<TPath>
1318
- | RouteHandler
1319
- | (new () => ActionHandlerClass)
1320
- /**
1321
- * Controller method reference with strict typing
1322
- */
1323
- export type ControllerMethod<TController extends string = string, TMethod extends string = string> = `${TController}@${TMethod}`
1324
- /**
1325
- * Discriminated union for different action handler types
1326
- */
1327
- export type ActionHandlerVariant<TPath extends string = string> = | { type: 'path', value: ActionPath }
1328
- | { type: 'function', value: TypedRouteHandler<TPath> }
1329
- | { type: 'class', value: new () => TypedActionHandlerClass<TPath> }
1330
- | { type: 'controller', value: ControllerMethod }
1331
- export type NextFunction = () => Promise<Response | null> | Response | null
1332
- export type MiddlewareHandler = (req: EnhancedRequest, next: NextFunction) => Promise<Response | null> | Response | null
1333
- export type Compressor = | 'disable'
1334
- | 'shared'
1335
- | 'dedicated'
1336
- | '3KB'
1337
- | '4KB'
1338
- | '8KB'
1339
- | '16KB'
1340
- | '32KB'
1341
- | '64KB'
1342
- | '128KB'
1343
- | '256KB'
1344
- /**
1345
- * HTTP Methods type - extremely narrow
1346
- */
1347
- export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD' | 'TRACE' | 'CONNECT'
1348
- /**
1349
- * Narrow throttle pattern types
1350
- */
1351
- export type ThrottlePattern = | `${number}` // e.g., "60" (60 requests per 1 minute)
1352
- | `${number},${number}` // e.g., "60,1" (60 requests per 1 minute)
1353
- | `${number},${number}min` // e.g., "60,5min" (60 requests per 5 minutes)
1354
- | `${number},${number}m` // e.g., "60,5m" (60 requests per 5 minutes)
1355
- | `${number},${number}sec` // e.g., "100,30sec" (100 requests per 30 seconds)
1356
- | `${number},${number}s` // e.g., "100,30s" (100 requests per 30 seconds)
1357
- | `${number},${number}hour` // e.g., "1000,1hour" (1000 requests per 1 hour)
1358
- | `${number},${number}h`
1359
- /**
1360
- * Cache strategy types - narrow and specific
1361
- */
1362
- export type CacheStrategy = 'stale-while-revalidate' | 'cache-first' | 'network-first'
1363
- /**
1364
- * Cache type narrow definition
1365
- */
1366
- export type CacheType = 'memory' | 'redis' | 'custom'
1367
- /**
1368
- * File extension types for views
1369
- */
1370
- export type ViewExtension = '.html' | '.stx' | '.hbs' | '.ejs' | '.pug' | '.mustache'
1371
- /**
1372
- * Template engine types
1373
- */
1374
- export type TemplateEngine = 'auto' | 'stx' | 'html' | 'handlebars' | 'ejs' | 'pug' | 'mustache' | 'custom'
1375
- /**
1376
- * Route parameter constraint patterns
1377
- */
1378
- export type RouteConstraint = | 'number' // Only numbers
1379
- | 'alpha' // Only letters
1380
- | 'alphanumeric' // Letters and numbers
1381
- | 'uuid' // UUID format
1382
- | 'slug' // URL-friendly slug
1383
- | RegExp // Custom regex
1384
- | string
1385
- /**
1386
- * Middleware execution timing
1387
- */
1388
- export type MiddlewareTiming = 'before' | 'after' | 'around'
1389
- /**
1390
- * Security header types
1391
- */
1392
- export type SecurityHeader = | 'Content-Security-Policy'
1393
- | 'X-Frame-Options'
1394
- | 'X-Content-Type-Options'
1395
- | 'Referrer-Policy'
1396
- | 'Permissions-Policy'
1397
- | 'Strict-Transport-Security'
1398
- /**
1399
- * Built-in middleware names - extremely narrow
1400
- */
1401
- export type BuiltInMiddleware = | 'auth'
1402
- | 'cors'
1403
- | 'csrf'
1404
- | 'helmet'
1405
- | 'json'
1406
- | 'compress'
1407
- | 'static'
1408
- | 'session'
1409
- | 'rateLimiter'
1410
- | 'requestId'
1411
- | 'logger'
1412
- | 'throttle'
1413
- /**
1414
- * Middleware with parameters
1415
- */
1416
- export type MiddlewareWithParams<T extends string = string> = | T
1417
- | `${T}:${string}`
1418
- /**
1419
- * Route path parameter types - narrow template literals
1420
- */
1421
- export type RouteParam<T extends string> = T extends `{${infer P}}` ? P : never
1422
- /**
1423
- * Extract parameters from route path
1424
- */
1425
- export type ExtractRouteParams<T extends string> = T extends `${string}{${infer Param}}${infer Rest}`
1426
- ? { [K in Param]: string } & ExtractRouteParams<Rest>
1427
- : object
1428
- /**
1429
- * Route method constraints
1430
- */
1431
- export type RouteMethodConstraint<M extends HTTPMethod = HTTPMethod> = M
1432
- /**
1433
- * File MIME types for uploads
1434
- */
1435
- export type AllowedMimeType = | 'image/jpeg'
1436
- | 'image/png'
1437
- | 'image/gif'
1438
- | 'image/webp'
1439
- | 'image/svg+xml'
1440
- | 'application/pdf'
1441
- | 'application/json'
1442
- | 'text/plain'
1443
- | 'text/csv'
1444
- | 'application/octet-stream'
1445
- /**
1446
- * Response status codes - narrow and specific
1447
- */
1448
- export type ResponseStatus = | 200 | 201 | 202 | 204 // Success
1449
- | 301 | 302 | 304 // Redirects
1450
- | 400 | 401 | 403 | 404 | 405 | 409 | 422 | 429 // Client errors
1451
- | 500 | 502 | 503 | 504
1452
- /**
1453
- * Content types - narrow
1454
- */
1455
- export type ContentType = | 'application/json'
1456
- | 'application/xml'
1457
- | 'text/html'
1458
- | 'text/plain'
1459
- | 'text/csv'
1460
- | 'application/pdf'
1461
- | 'application/octet-stream'
1462
- | 'multipart/form-data'
1463
- | 'application/x-www-form-urlencoded'
1464
- /**
1465
- * Union of all typed route definitions
1466
- */
1467
- export type TypedRouteDefinition<TPath extends string = string> = | GetRoute<TPath>
1468
- | PostRoute<TPath>
1469
- | PutRoute<TPath>
1470
- | DeleteRoute<TPath>
1471
- | PatchRoute<TPath>
1472
- /**
1473
- * Common route patterns with strict template literal types
1474
- */
1475
- export type CommonRoutePatterns = | '/' // Root
1476
- | '/health' // Health check
1477
- | '/api' // API root
1478
- | '/api/v1' // Versioned API
1479
- | '/api/v1/users' // User collection
1480
- | '/api/v1/users/{id}' // User resource
1481
- | '/api/v1/users/{userId}/posts' // Nested resource
1482
- | '/api/v1/users/{userId}/posts/{postId}' // Nested resource item
1483
- | '/admin' // Admin panel
1484
- | '/admin/{section}' // Admin section
1485
- | '/auth/login' // Authentication
1486
- | '/auth/logout' // Logout
1487
- | '/auth/register' // Registration
1488
- | '/auth/forgot-password' // Password reset
1489
- | '/uploads/{filename}' // File uploads
1490
- | '/assets/{path}'
1491
- /**
1492
- * RESTful resource route patterns
1493
- */
1494
- export type ResourceRoutePatterns<T extends string> = | `/${T}` // Collection: GET /users
1495
- | `/${T}/{id}` // Item: GET /users/123
1496
- | `/${T}/create` // Create form: GET /users/create
1497
- | `/${T}/{id}/edit` // Edit form: GET /users/123/edit
1498
- | `/${T}/{id}/show`
1499
- /**
1500
- * API versioning patterns
1501
- */
1502
- export type ApiVersionPattern<V extends string, Path extends string> = `/api/${V}${Path}`
1503
- /**
1504
- * Nested resource patterns
1505
- */
1506
- export type NestedResourcePattern<Parent extends string, Child extends string, ParentId extends string = 'id', ChildId extends string = 'id'> = `/${Parent}/{${ParentId}}/${Child}` | `/${Parent}/{${ParentId}}/${Child}/{${ChildId}}`
1507
- /**
1508
- * Route parameter patterns with constraints
1509
- */
1510
- export type IdPattern = '{id}'
1511
- export type UuidPattern = '{uuid}'
1512
- export type SlugPattern = '{slug}'
1513
- export type NumberPattern = '{number}'
1514
- /**
1515
- * File path patterns
1516
- */
1517
- export type FilePathPattern = '{filepath}' | '{*filepath}' | '{path...}'
1518
- /**
1519
- * Discriminated union for cache configurations
1520
- */
1521
- export type CacheConfigVariant = | { type: 'memory', maxSize: number, ttl: number }
1522
- | { type: 'redis', url: string, prefix: string, ttl: number, maxRetries: number }
1523
- | { type: 'custom', adapter: CacheConfig['customAdapter'], ttl: number }
1524
- /**
1525
- * Discriminated union for authentication configurations
1526
- */
1527
- export type AuthConfigVariant = | { type: 'jwt', secret: string, expiresIn: string, algorithm: 'HS256' | 'HS384' | 'HS512' | 'RS256' }
1528
- | { type: 'session', secret: string, store: CacheType, maxAge: number }
1529
- | { type: 'apikey', keyName: string, location: 'header' | 'query' | 'cookie' }
1530
- | { type: 'basic', realm: string, users: Record<string, string> }
1531
- | { type: 'bearer', validate: (token: string) => Promise<boolean> }
1532
- /**
1533
- * Discriminated union for rate limiting configurations
1534
- */
1535
- export type RateLimitConfigVariant = | { type: 'memory', maxAttempts: number, windowMs: number, keyGenerator?: (req: EnhancedRequest) => string }
1536
- | { type: 'redis', maxAttempts: number, windowMs: number, redisUrl: string, keyPrefix: string }
1537
- | { type: 'pattern', pattern: ThrottlePattern, name?: string }
1538
- /**
1539
- * Discriminated union for middleware configurations
1540
- */
1541
- export type MiddlewareConfigVariant = | { type: 'throttle', config: RateLimitConfigVariant }
1542
- | { type: 'cors', config: CorsMiddlewareConfig }
1543
- | { type: 'auth', config: AuthConfigVariant }
1544
- | { type: 'cache', config: CacheConfigVariant }
1545
- | { type: 'custom', name: string, handler: MiddlewareHandler, params?: MiddlewareParams }
1546
- /**
1547
- * Discriminated union for route handlers
1548
- */
1549
- export type RouteHandlerVariant<TPath extends string = string> = | { type: 'action', path: ActionPath }
1550
- | { type: 'function', handler: TypedRouteHandler<TPath> }
1551
- | { type: 'class', constructor: new () => TypedActionHandlerClass<TPath> }
1552
- | { type: 'controller', method: ControllerMethod }
1553
- /**
1554
- * Discriminated union for validation rules
1555
- */
1556
- export type ValidationRuleVariant = | { type: 'required', message?: string }
1557
- | { type: 'string', minLength?: number, maxLength?: number, pattern?: RegExp }
1558
- | { type: 'number', min?: number, max?: number, integer?: boolean }
1559
- | { type: 'email', message?: string }
1560
- | { type: 'url', protocols?: string[] }
1561
- | { type: 'custom', validate: (value: unknown) => boolean | Promise<boolean>, message: string }
1562
- /**
1563
- * Streaming configuration types with extreme narrowing
1564
- */
1565
- export type StreamingFormat = 'json' | 'ndjson' | 'csv' | 'xml' | 'text' | 'binary'
1566
- export type StreamingCompression = 'gzip' | 'deflate' | 'br' | 'none'
1567
- export type StreamingMode = 'chunked' | 'buffered' | 'direct'
1568
- /**
1569
- * Stream generator function types
1570
- */
1571
- export type SSEGenerator<T = unknown> = () => AsyncGenerator<SSEEvent<T>, void, unknown>
1572
- /**
1573
- * Model resolver function type
1574
- */
1575
- export type ModelResolver<T = any> = (
1576
- params: Record<string, string>,
1577
- req: EnhancedRequest
1578
- ) => T | Promise<T> | null
1579
- /**
1580
- * Model validator function type
1581
- */
1582
- export type ModelValidatorFn<T = any> = (
1583
- model: T,
1584
- params: Record<string, string>,
1585
- req?: EnhancedRequest
1586
- ) => Promise<{ valid: boolean, error?: string, status?: number }> | { valid: boolean, error?: string, status?: number }
1587
- /**
1588
- * Model transformer function type
1589
- */
1590
- export type ModelTransformerFn<T = any> = (
1591
- model: T,
1592
- params?: Record<string, string>,
1593
- req?: EnhancedRequest
1594
- ) => any | Promise<any>
1595
- /**
1596
- * Async generator function type for streaming
1597
- */
1598
- export type StreamGenerator<T = unknown> = () => AsyncGenerator<T, void, unknown>
1599
- /**
1600
- * Direct stream handler function type
1601
- */
1602
- export type DirectStreamHandler = (writer: DirectStreamWriter) => Promise<void>
1603
- /**
1604
- * Buffered stream handler function type
1605
- */
1606
- export type BufferedStreamHandler = (writer: BufferedStreamWriter) => Promise<void>
1607
- /**
1608
- * Transform function type for stream transformation
1609
- */
1610
- export type TransformFunction<T = Uint8Array, R = string | Uint8Array> = (chunk: T) => R | Promise<R>
1611
- /**
1612
- * Enhanced streaming generator types with extreme narrowing
1613
- */
1614
- export type StreamGeneratorSync<T = string | Uint8Array> = () => Generator<T, void, unknown>
1615
- export type AsyncStreamGenerator<T = string | Uint8Array> = () => AsyncGenerator<T, void, unknown>
1616
- export type StreamCallbackGenerator<T = string | Uint8Array> = StreamGenerator<T> | AsyncStreamGenerator<T>
1617
- /**
1618
- * SSE Event generator with strict typing
1619
- */
1620
- export type SSEEventGenerator<T = unknown> = () => Generator<SSEEvent<T>, void, unknown> | AsyncGenerator<SSEEvent<T>, void, unknown>