blaizejs 0.2.3 → 0.3.1

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.
package/dist/index.d.cts CHANGED
@@ -1,57 +1,670 @@
1
+ import { z } from 'zod';
1
2
  import http, { IncomingMessage, ServerResponse } from 'node:http';
2
3
  import http2, { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
4
+ import { WriteStream } from 'node:fs';
5
+ import { Readable } from 'node:stream';
3
6
  import { AsyncLocalStorage } from 'node:async_hooks';
4
- import { z } from 'zod';
5
7
  import { EventEmitter } from 'node:events';
6
8
 
7
9
  /**
8
- * Compose multiple middleware functions into a single middleware function
10
+ * Error type definitions and interfaces for the BlaizeJS framework
11
+ *
12
+ * This module contains all the type definitions used for error handling
13
+ * across the BlaizeJS framework, including server-side errors, client-side
14
+ * errors, and HTTP response formats.
9
15
  */
10
- declare function compose(middlewareStack: Middleware[]): MiddlewareFunction;
11
-
12
16
  /**
13
- * Create a middleware
17
+ * Structure of error responses sent over HTTP
18
+ *
19
+ * This interface defines the JSON format used for all error responses
20
+ * from BlaizeJS servers. It matches the structure returned by BlaizeError.toJSON()
21
+ *
22
+ * @example
23
+ * ```json
24
+ * {
25
+ * "type": "VALIDATION_ERROR",
26
+ * "title": "Request validation failed",
27
+ * "status": 400,
28
+ * "correlationId": "req_abc123",
29
+ * "timestamp": "2024-01-15T10:30:00.000Z",
30
+ * "details": {
31
+ * "fields": ["email", "password"]
32
+ * }
33
+ * }
34
+ * ```
14
35
  */
15
- declare function create$2(handlerOrOptions: MiddlewareFunction | MiddlewareOptions): Middleware;
16
-
36
+ interface BlaizeErrorResponse {
37
+ /** Error type from the ErrorType enum */
38
+ type: ErrorType;
39
+ /** Human-readable error message */
40
+ title: string;
41
+ /** HTTP status code */
42
+ status: number;
43
+ /** Correlation ID for request tracing */
44
+ correlationId: string;
45
+ /** ISO timestamp when error occurred */
46
+ timestamp: string;
47
+ /** Optional error-specific details */
48
+ details?: unknown;
49
+ }
17
50
  /**
18
- * Create a plugin with the given name, version, and setup function
51
+ * Context information for network-related errors
52
+ *
53
+ * Used by client-side error classes to provide additional context
54
+ * about network failures, timeouts, and connection issues.
19
55
  */
20
- declare function create$1<T = any>(name: string, version: string, setup: (app: Server, options: T) => void | Partial<PluginHooks> | Promise<void> | Promise<Partial<PluginHooks>>, defaultOptions?: Partial<T>): PluginFactory<T>;
21
-
56
+ interface NetworkErrorContext {
57
+ /** The URL that failed */
58
+ url: string;
59
+ /** HTTP method being attempted */
60
+ method: string;
61
+ /** Correlation ID for tracing */
62
+ correlationId: string;
63
+ /** Timeout value if applicable */
64
+ timeout?: number;
65
+ /** The original error that caused the network failure */
66
+ originalError: Error;
67
+ /** Additional network-specific details */
68
+ networkDetails?: {
69
+ /** Whether this was a connection timeout */
70
+ isTimeout?: boolean;
71
+ /** Whether this was a DNS resolution failure */
72
+ isDnsFailure?: boolean;
73
+ /** Whether this was a connection refused error */
74
+ isConnectionRefused?: boolean;
75
+ /** HTTP status code if received before failure */
76
+ statusCode?: number;
77
+ };
78
+ }
22
79
  /**
23
- * Create a GET route
80
+ * Context information for request timeout errors
81
+ *
82
+ * Specialized context for timeout-specific errors with timing information.
24
83
  */
25
- declare const createGetRoute: CreateGetRoute;
84
+ interface TimeoutErrorContext {
85
+ /** The URL that timed out */
86
+ url: string;
87
+ /** HTTP method being attempted */
88
+ method: string;
89
+ /** Correlation ID for tracing */
90
+ correlationId: string;
91
+ /** Configured timeout value in milliseconds */
92
+ timeoutMs: number;
93
+ /** Actual duration before timeout in milliseconds */
94
+ elapsedMs: number;
95
+ /** Type of timeout (request, connection, etc.) */
96
+ timeoutType: 'request' | 'connection' | 'response' | 'idle';
97
+ }
26
98
  /**
27
- * Create a POST route
99
+ * Context information for response parsing errors
100
+ *
101
+ * Used when the client receives a response but cannot parse it properly.
28
102
  */
29
- declare const createPostRoute: CreatePostRoute;
103
+ interface ParseErrorContext {
104
+ /** The URL that returned unparseable content */
105
+ url: string;
106
+ /** HTTP method used */
107
+ method: string;
108
+ /** Correlation ID for tracing */
109
+ correlationId: string;
110
+ /** HTTP status code received */
111
+ statusCode: number;
112
+ /** Content-Type header if available */
113
+ contentType?: string;
114
+ /** Expected response format */
115
+ expectedFormat: 'json' | 'text' | 'binary';
116
+ /** Sample of the actual response content (truncated for safety) */
117
+ responseSample?: string;
118
+ /** The original parsing error */
119
+ originalError: Error;
120
+ }
30
121
  /**
31
- * Create a PUT route
122
+ * Validation error field details
123
+ *
124
+ * Structure for field-level validation errors with multiple error messages
125
+ * per field.
32
126
  */
33
- declare const createPutRoute: CreatePutRoute;
127
+ interface ValidationFieldError {
128
+ /** Field name or path (e.g., "email", "user.profile.name") */
129
+ field: string;
130
+ /** Array of error messages for this field */
131
+ messages: string[];
132
+ /** The invalid value that caused the error */
133
+ rejectedValue?: unknown;
134
+ /** Expected type or format */
135
+ expectedType?: string;
136
+ }
34
137
  /**
35
- * Create a DELETE route
138
+ * Validation error details structure
139
+ *
140
+ * Used by ValidationError to provide structured information about
141
+ * what fields failed validation and why.
36
142
  */
37
- declare const createDeleteRoute: CreateDeleteRoute;
143
+ interface ValidationErrorDetails {
144
+ /** Array of field-level errors */
145
+ fields: ValidationFieldError[];
146
+ /** Total number of validation errors */
147
+ errorCount: number;
148
+ /** The section that failed validation */
149
+ section: 'params' | 'query' | 'body' | 'response';
150
+ /** Schema name if available */
151
+ schemaName?: string;
152
+ }
38
153
  /**
39
- * Create a PATCH route
154
+ * All available error types in the BlaizeJS framework
155
+ *
156
+ * This enum provides both compile-time type safety and runtime values
157
+ * for error type identification across server and client packages.
158
+ *
159
+ * @example Type-safe error handling:
160
+ * ```typescript
161
+ * function handleError(errorType: ErrorType) {
162
+ * switch (errorType) {
163
+ * case ErrorType.VALIDATION_ERROR:
164
+ * // Handle validation error
165
+ * break;
166
+ * case ErrorType.NOT_FOUND:
167
+ * // Handle not found error
168
+ * break;
169
+ * // TypeScript ensures all cases are covered
170
+ * }
171
+ * }
172
+ * ```
40
173
  */
41
- declare const createPatchRoute: CreatePatchRoute;
174
+ declare enum ErrorType {
175
+ /** Request validation failed (400) */
176
+ VALIDATION_ERROR = "VALIDATION_ERROR",
177
+ /** Resource not found (404) */
178
+ NOT_FOUND = "NOT_FOUND",
179
+ /** Authentication required (401) */
180
+ UNAUTHORIZED = "UNAUTHORIZED",
181
+ /** Access forbidden (403) */
182
+ FORBIDDEN = "FORBIDDEN",
183
+ /** Resource conflict (409) */
184
+ CONFLICT = "CONFLICT",
185
+ /** Rate limit exceeded (429) */
186
+ RATE_LIMITED = "RATE_LIMITED",
187
+ /** Internal server error (500) */
188
+ INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR",
189
+ /** File/Request Too Large (413) */
190
+ PAYLOAD_TOO_LARGE = "PAYLOAD_TOO_LARGE",
191
+ /** Wrong Content Type (415) */
192
+ UNSUPPORTED_MEDIA_TYPE = "UNSUPPORTED_MEDIA_TYPE",
193
+ /** Upload Timeout (408) */
194
+ UPLOAD_TIMEOUT = "UPLOAD_TIMEOUT",
195
+ /** Valid Format Invalid Semantics (422) */
196
+ UNPROCESSABLE_ENTITY = "UNPROCESSABLE_ENTITY",
197
+ /** Network connectivity failure (0) */
198
+ NETWORK_ERROR = "NETWORK_ERROR",
199
+ /** Request or response timeout (0) */
200
+ TIMEOUT_ERROR = "TIMEOUT_ERROR",
201
+ /** Response parsing failure (0) */
202
+ PARSE_ERROR = "PARSE_ERROR",
203
+ /** Generic HTTP error (varies) */
204
+ HTTP_ERROR = "HTTP_ERROR"
205
+ }
42
206
  /**
43
- * Create a HEAD route (same signature as GET - no body)
207
+ * Error severity levels for logging and monitoring
208
+ *
209
+ * Provides a way to categorize errors by their impact and urgency.
44
210
  */
45
- declare const createHeadRoute: CreateHeadRoute;
211
+ declare enum ErrorSeverity {
212
+ /** Low impact, often user errors */
213
+ LOW = "low",
214
+ /** Medium impact, application errors */
215
+ MEDIUM = "medium",
216
+ /** High impact, system errors */
217
+ HIGH = "high",
218
+ /** Critical impact, service disruption */
219
+ CRITICAL = "critical"
220
+ }
46
221
  /**
47
- * Create an OPTIONS route (same signature as GET - no body)
222
+ * Abstract base class for all BlaizeJS errors
223
+ *
224
+ * This class provides the foundation for all error types in the BlaizeJS framework.
225
+ * It extends JavaScript's built-in Error class and adds framework-specific properties
226
+ * for consistent error handling across server and client.
227
+ *
228
+ * @example
229
+ * ```typescript
230
+ * import { ErrorType } from './types';
231
+ *
232
+ * class NotFoundError extends BlaizeError<{ resourceId: string }> {
233
+ * constructor(message = 'Resource not found', details?: { resourceId: string }) {
234
+ * super(ErrorType.NOT_FOUND, message, 404, getCurrentCorrelationId(), details);
235
+ * }
236
+ * }
237
+ * ```
238
+ *
239
+ * @template TDetails - Type for error-specific details object
48
240
  */
49
- declare const createOptionsRoute: CreateOptionsRoute;
241
+ declare abstract class BlaizeError<TDetails = unknown> extends Error {
242
+ /**
243
+ * Error type identifier from the ErrorType enum
244
+ * Used for programmatic error handling and client-side error routing
245
+ */
246
+ readonly type: ErrorType;
247
+ /**
248
+ * Human-readable error title/message
249
+ * Should be descriptive enough for debugging but safe for end users
250
+ */
251
+ readonly title: string;
252
+ /**
253
+ * HTTP status code associated with this error
254
+ * Used by the error boundary to set appropriate response status
255
+ */
256
+ readonly status: number;
257
+ /**
258
+ * Correlation ID for request tracing
259
+ * Links this error to the specific request that generated it
260
+ */
261
+ readonly correlationId: string;
262
+ /**
263
+ * Timestamp when the error occurred
264
+ * Useful for debugging and log correlation
265
+ */
266
+ readonly timestamp: Date;
267
+ /**
268
+ * Additional error-specific details
269
+ * Type-safe error context that varies by error type
270
+ */
271
+ readonly details?: TDetails | undefined;
272
+ /**
273
+ * Creates a new BlaizeError instance
274
+ *
275
+ * @param type - Error type from the ErrorType enum
276
+ * @param title - Human-readable error message
277
+ * @param status - HTTP status code
278
+ * @param correlationId - Request correlation ID for tracing
279
+ * @param details - Optional error-specific details
280
+ */
281
+ protected constructor(type: ErrorType, title: string, status: number, correlationId: string, details?: TDetails | undefined);
282
+ /**
283
+ * Serializes the error to a plain object suitable for HTTP responses
284
+ *
285
+ * @returns Object representation of the error
286
+ */
287
+ toJSON(): {
288
+ type: ErrorType;
289
+ title: string;
290
+ status: number;
291
+ correlationId: string;
292
+ timestamp: string;
293
+ } | {
294
+ details: TDetails & ({} | null);
295
+ type: ErrorType;
296
+ title: string;
297
+ status: number;
298
+ correlationId: string;
299
+ timestamp: string;
300
+ };
301
+ /**
302
+ * Returns a string representation of the error
303
+ * Includes correlation ID for easier debugging
304
+ */
305
+ toString(): string;
306
+ }
307
+ /**
308
+ * Interface for payload too large error details
309
+ */
310
+ interface PayloadTooLargeErrorDetails {
311
+ fileCount?: number;
312
+ maxFiles?: number;
313
+ filename?: string;
314
+ field?: string;
315
+ contentType?: string;
316
+ currentSize?: number;
317
+ maxSize?: number;
318
+ }
319
+ /**
320
+ * Interface for unsupported media type error details
321
+ */
322
+ interface UnsupportedMediaTypeErrorDetails {
323
+ receivedMimeType?: string;
324
+ allowedMimeTypes?: string[];
325
+ filename?: string;
326
+ }
327
+ /**
328
+ * Interface for authentication error details
329
+ */
330
+ interface UnauthorizedErrorDetails {
331
+ /** Reason for authentication failure */
332
+ reason?: 'missing_token' | 'invalid_token' | 'expired_token' | 'malformed_token' | 'insufficient_scope' | string;
333
+ /** Authentication scheme (Bearer, Basic, etc.) */
334
+ authScheme?: string;
335
+ /** Authentication realm */
336
+ realm?: string;
337
+ /** Detailed error description */
338
+ error_description?: string;
339
+ /** Required scopes or permissions */
340
+ requiredScopes?: string[];
341
+ /** Login URL for interactive authentication */
342
+ loginUrl?: string;
343
+ /** Additional context */
344
+ [key: string]: unknown;
345
+ }
346
+ /**
347
+ * Interface for authorization/permission error details
348
+ */
349
+ interface ForbiddenErrorDetails {
350
+ /** Required permission or role */
351
+ requiredPermission?: string;
352
+ /** User's current permissions */
353
+ userPermissions?: string[];
354
+ /** Resource being accessed */
355
+ resource?: string;
356
+ /** Action being attempted */
357
+ action?: string;
358
+ /** Reason for access denial */
359
+ reason?: 'insufficient_permissions' | 'account_suspended' | 'resource_locked' | string;
360
+ /** Additional context */
361
+ [key: string]: unknown;
362
+ }
363
+ /**
364
+ * Interface for resource conflict error details
365
+ */
366
+ interface ConflictErrorDetails {
367
+ /** Type of conflict */
368
+ conflictType?: 'duplicate_key' | 'version_mismatch' | 'concurrent_modification' | 'business_rule' | string;
369
+ /** Field that caused the conflict */
370
+ field?: string;
371
+ /** Existing value that conflicts */
372
+ existingValue?: unknown;
373
+ /** Provided value that conflicts */
374
+ providedValue?: unknown;
375
+ /** Resource that has the conflicting value */
376
+ conflictingResource?: string;
377
+ /** Current version/etag of the resource */
378
+ currentVersion?: string;
379
+ /** Expected version/etag */
380
+ expectedVersion?: string;
381
+ /** Suggested resolution */
382
+ resolution?: string;
383
+ /** Additional context */
384
+ [key: string]: unknown;
385
+ }
386
+ /**
387
+ * Interface for rate limiting error details
388
+ */
389
+ interface RateLimitErrorDetails {
390
+ /** Maximum requests allowed in the time window */
391
+ limit?: number;
392
+ /** Remaining requests in current window */
393
+ remaining?: number;
394
+ /** When the rate limit resets */
395
+ resetTime?: Date;
396
+ /** Seconds until the rate limit resets */
397
+ retryAfter?: number;
398
+ /** Time window for the rate limit */
399
+ window?: string;
400
+ /** Identifier used for rate limiting (IP, user ID, etc.) */
401
+ identifier?: string;
402
+ /** Type of rate limit hit */
403
+ limitType?: 'global' | 'per_user' | 'per_ip' | 'per_endpoint' | string;
404
+ /** Additional context */
405
+ [key: string]: unknown;
406
+ }
407
+ /**
408
+ * Interface for internal server error details
409
+ */
410
+ interface InternalServerErrorDetails {
411
+ /** Original error message (for debugging) */
412
+ originalError?: string;
413
+ /** Stack trace (for debugging) */
414
+ stackTrace?: string;
415
+ /** Component where the error occurred */
416
+ component?: string;
417
+ /** Operation being performed */
418
+ operation?: string;
419
+ /** Internal error code */
420
+ internalErrorCode?: string;
421
+ /** When the error occurred */
422
+ timestamp?: Date;
423
+ /** Whether this error should be retryable */
424
+ retryable?: boolean;
425
+ /** Additional debugging context */
426
+ [key: string]: unknown;
427
+ }
428
+ /**
429
+ * Interface for NotFound error details
430
+ * Provides context about the missing resource
431
+ */
432
+ interface NotFoundErrorDetails {
433
+ /** Type of resource that was not found */
434
+ resourceType?: string;
435
+ /** ID or identifier of the resource */
436
+ resourceId?: string;
437
+ /** Collection or table where the resource was searched */
438
+ collection?: string;
439
+ /** Search criteria that was used */
440
+ query?: Record<string, unknown>;
441
+ /** Search criteria that was used (for backward compatibility) */
442
+ searchCriteria?: Record<string, unknown>;
443
+ /** The path that was attempted */
444
+ path?: string;
445
+ /** HTTP method used (for API endpoints) */
446
+ method?: string;
447
+ /** The path that was attempted (for backward compatibility) */
448
+ attemptedPath?: string;
449
+ /** Parent resource information for nested resources */
450
+ parentResource?: {
451
+ type: string;
452
+ id: string;
453
+ };
454
+ /** Helpful suggestion for the user */
455
+ suggestion?: string;
456
+ /** Additional context */
457
+ [key: string]: unknown;
458
+ }
459
+ /**
460
+ * Interface for body parsing errors stored in context state
461
+ */
462
+ interface BodyParseError {
463
+ /**
464
+ * Type of parsing error that occurred
465
+ */
466
+ readonly type: 'json_parse_error' | 'form_parse_error' | 'multipart_parse_error' | 'body_read_error';
467
+ /**
468
+ * Human-readable error message
469
+ */
470
+ readonly message: string;
471
+ /**
472
+ * Original error object or details
473
+ */
474
+ readonly error: unknown;
475
+ }
476
+ /**
477
+ * Type guard to check if an object is a BodyParseError
478
+ */
479
+ declare function isBodyParseError(error: unknown): error is BodyParseError;
480
+ /**
481
+ * Context information for error transformation
482
+ */
483
+ interface ErrorTransformContext {
484
+ url: string;
485
+ method: string;
486
+ correlationId: string;
487
+ timeoutMs?: number;
488
+ elapsedMs?: number;
489
+ statusCode?: number;
490
+ contentType?: string;
491
+ responseSample?: string;
492
+ [key: string]: unknown;
493
+ }
50
494
 
51
495
  /**
52
- * Creates a BlaizeJS server instance
496
+ * Represents an uploaded file in a multipart/form-data request
53
497
  */
54
- declare function create(options?: ServerOptionsInput): Server;
498
+ interface UploadedFile {
499
+ /** Original filename provided by the client (may be undefined) */
500
+ readonly filename: string | undefined;
501
+ /** Form field name this file was uploaded under */
502
+ readonly fieldname: string;
503
+ /** MIME type of the uploaded file */
504
+ readonly mimetype: string;
505
+ /** Size of the file in bytes */
506
+ readonly size: number;
507
+ /** Stream containing the file data (always available) */
508
+ readonly stream: Readable;
509
+ /** Buffer containing file data (only available with 'memory' strategy) */
510
+ readonly buffer?: Buffer;
511
+ /** Path to temporary file (only available with 'temp' strategy) */
512
+ readonly tempPath?: string;
513
+ /** SHA-256 hash of file content (if computed) */
514
+ readonly hash?: string;
515
+ }
516
+ /**
517
+ * Complete multipart/form-data parsed content
518
+ */
519
+ interface MultipartData {
520
+ /** Form fields (non-file inputs) */
521
+ readonly fields: Record<string, string | string[]>;
522
+ /** Uploaded files */
523
+ readonly files: Record<string, UploadedFile | UploadedFile[]>;
524
+ }
525
+ /**
526
+ * Options for parsing multipart/form-data
527
+ */
528
+ interface ParseOptions {
529
+ /** Maximum size for individual files in bytes (default: 10MB) */
530
+ readonly maxFileSize?: number;
531
+ /** Maximum number of files per request (default: 10) */
532
+ readonly maxFiles?: number;
533
+ /** Maximum size for form fields in bytes (default: 1MB) */
534
+ readonly maxFieldSize?: number;
535
+ /** Allowed MIME types (empty array = allow all) */
536
+ readonly allowedMimeTypes?: readonly string[];
537
+ /** Allowed file extensions (empty array = allow all) */
538
+ readonly allowedExtensions?: readonly string[];
539
+ /** Processing strategy for file data */
540
+ readonly strategy: 'memory' | 'stream' | 'temp';
541
+ /** Directory for temporary files (strategy: 'temp' only) */
542
+ readonly tempDir?: string;
543
+ /** Whether to compute SHA-256 hash of files */
544
+ readonly computeHash?: boolean;
545
+ }
546
+ /**
547
+ * Result of parsing multipart data with metadata
548
+ */
549
+ interface ParseResult {
550
+ /** Parsed multipart data */
551
+ readonly data: MultipartData;
552
+ /** Parsing metadata */
553
+ readonly metadata: {
554
+ /** Total time spent parsing (milliseconds) */
555
+ readonly parseTime: number;
556
+ /** Total size of all uploaded content */
557
+ readonly totalSize: number;
558
+ /** Number of files processed */
559
+ readonly fileCount: number;
560
+ /** Number of fields processed */
561
+ readonly fieldCount: number;
562
+ };
563
+ }
564
+ /**
565
+ * Error information for multipart parsing failures
566
+ */
567
+ interface MultipartError {
568
+ /** Error type/code */
569
+ readonly type: 'boundary_missing' | 'size_exceeded' | 'file_limit_exceeded' | 'mime_type_forbidden' | 'extension_forbidden' | 'parse_error' | 'stream_error' | 'temp_file_error';
570
+ /** Human-readable error message */
571
+ readonly message: string;
572
+ /** Additional context (field name, file name, etc.) */
573
+ readonly context?: Record<string, unknown>;
574
+ /** Original error if available */
575
+ readonly cause?: Error;
576
+ }
577
+ /**
578
+ * Configuration for file upload validation
579
+ */
580
+ interface ValidationConfig {
581
+ /** File size constraints */
582
+ readonly size?: {
583
+ readonly min?: number;
584
+ readonly max?: number;
585
+ };
586
+ /** File count constraints */
587
+ readonly count?: {
588
+ readonly min?: number;
589
+ readonly max?: number;
590
+ };
591
+ /** MIME type constraints */
592
+ readonly mimeTypes?: {
593
+ readonly allowed?: readonly string[];
594
+ readonly forbidden?: readonly string[];
595
+ };
596
+ /** File extension constraints */
597
+ readonly extensions?: {
598
+ readonly allowed?: readonly string[];
599
+ readonly forbidden?: readonly string[];
600
+ };
601
+ /** Custom validation function */
602
+ readonly custom?: (file: UploadedFile) => Promise<boolean> | boolean;
603
+ }
604
+ /**
605
+ * File processing configuration
606
+ */
607
+ interface ProcessingConfig {
608
+ /** Whether to process files concurrently */
609
+ readonly concurrent?: boolean;
610
+ /** Maximum concurrent processing operations */
611
+ readonly maxConcurrency?: number;
612
+ /** Processing timeout in milliseconds */
613
+ readonly timeout?: number;
614
+ /** Whether to preserve original files during processing */
615
+ readonly preserveOriginal?: boolean;
616
+ }
617
+ /**
618
+ * Upload progress information (for future streaming uploads)
619
+ */
620
+ interface UploadProgress {
621
+ /** Bytes uploaded so far */
622
+ readonly bytesUploaded: number;
623
+ /** Total bytes to upload */
624
+ readonly totalBytes: number;
625
+ /** Upload percentage (0-100) */
626
+ readonly percentage: number;
627
+ /** Upload speed in bytes per second */
628
+ readonly speed: number;
629
+ /** Estimated time remaining in milliseconds */
630
+ readonly eta: number;
631
+ }
632
+ /**
633
+ * Internal state for multipart parser state machine
634
+ */
635
+ interface ParserState {
636
+ boundary: Buffer;
637
+ options: Required<ParseOptions>;
638
+ fields: Map<string, string[]>;
639
+ files: Map<string, UploadedFile[]>;
640
+ buffer: Buffer;
641
+ stage: 'boundary' | 'headers' | 'content';
642
+ currentHeaders: string;
643
+ currentField: string | null;
644
+ currentFilename: string | undefined;
645
+ currentMimetype: string;
646
+ currentContentLength: number;
647
+ fileCount: number;
648
+ fieldCount: number;
649
+ currentBufferChunks: Buffer[];
650
+ currentStream: Readable | null;
651
+ currentTempPath: string | null;
652
+ currentWriteStream: WriteStream | null;
653
+ streamController: ReadableStreamDefaultController<Uint8Array> | null;
654
+ cleanupTasks: Array<() => Promise<void>>;
655
+ /**
656
+ * Whether we've found at least one valid boundary marker
657
+ */
658
+ hasFoundValidBoundary: boolean;
659
+ /**
660
+ * Whether we've successfully processed at least one complete part (field or file)
661
+ */
662
+ hasProcessedAnyPart: boolean;
663
+ /**
664
+ * Whether parsing has reached the end boundary
665
+ */
666
+ isFinished: boolean;
667
+ }
55
668
 
56
669
  /**
57
670
  * Unified request type supporting both HTTP/1.1 and HTTP/2
@@ -87,6 +700,11 @@ interface StreamOptions {
87
700
  */
88
701
  interface State {
89
702
  [key: string]: unknown;
703
+ /**
704
+ * Body parsing error information
705
+ * Set when body parsing fails during request processing
706
+ */
707
+ _bodyError?: BodyParseError;
90
708
  }
91
709
  interface ContextResponse<S extends State = State> {
92
710
  raw: UnifiedResponse;
@@ -111,6 +729,16 @@ interface ContextRequest<TBody = unknown> {
111
729
  protocol: string;
112
730
  isHttp2: boolean;
113
731
  body?: TBody;
732
+ /**
733
+ * Uploaded files from multipart/form-data requests
734
+ * Available when Content-Type is multipart/form-data
735
+ */
736
+ files?: Record<string, UploadedFile | UploadedFile[]>;
737
+ /**
738
+ * Complete multipart data (files + fields)
739
+ * Available when Content-Type is multipart/form-data
740
+ */
741
+ multipart?: MultipartData;
114
742
  header: (name: string) => string | undefined;
115
743
  headers: (names?: string[]) => Record<string, string | undefined>;
116
744
  }
@@ -134,6 +762,12 @@ interface Context<S extends State = State, TBody = unknown, TQuery = QueryParams
134
762
  */
135
763
  state: S;
136
764
  }
765
+ type MultipartLimits = {
766
+ maxFileSize?: number;
767
+ maxTotalSize?: number;
768
+ maxFiles?: number;
769
+ maxFieldSize?: number;
770
+ };
137
771
  /**
138
772
  * Options for creating a context
139
773
  */
@@ -146,6 +780,16 @@ interface ContextOptions {
146
780
  * Additional state to merge into the context
147
781
  */
148
782
  initialState?: State;
783
+ /**
784
+ * Limits for various body types to prevent abuse
785
+ */
786
+ bodyLimits?: {
787
+ json?: number;
788
+ form?: number;
789
+ text?: number;
790
+ multipart?: MultipartLimits;
791
+ raw?: number;
792
+ };
149
793
  }
150
794
  /**
151
795
  * Function to get the current context from AsyncLocalStorage
@@ -207,7 +851,11 @@ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTION
207
851
  /**
208
852
  * Schema for route validation with generic type parameters
209
853
  */
210
- interface RouteSchema<P extends z.ZodType = z.ZodType<any>, Q extends z.ZodType = z.ZodType<any>, B extends z.ZodType = z.ZodType<any>, R extends z.ZodType = z.ZodType<any>> {
854
+ interface RouteSchema<P extends z.ZodType = z.ZodType<any>, // URL parameters schema
855
+ Q extends z.ZodType = z.ZodType<any>, // Query parameters schema
856
+ B extends z.ZodType = z.ZodType<any>, // Body schema
857
+ R extends z.ZodType = z.ZodType<any>, // Response schema
858
+ ED extends z.ZodType = z.ZodType<any>> {
211
859
  /** Parameter schema for validation */
212
860
  params?: P;
213
861
  /** Query schema for validation */
@@ -216,6 +864,8 @@ interface RouteSchema<P extends z.ZodType = z.ZodType<any>, Q extends z.ZodType
216
864
  body?: B;
217
865
  /** Response schema for validation */
218
866
  response?: R;
867
+ /** Error Response Details schema for validation */
868
+ errorResponseDetails?: ED;
219
869
  }
220
870
  /**
221
871
  * Route handler function with strongly typed params and response
@@ -224,9 +874,9 @@ type RouteHandler<TParams = Record<string, string>, TQuery = Record<string, stri
224
874
  /**
225
875
  * Options for a route method with schema-based type inference
226
876
  */
227
- interface RouteMethodOptions<P extends z.ZodType = z.ZodType<any>, Q extends z.ZodType = z.ZodType<any>, B extends z.ZodType = z.ZodType<any>, R extends z.ZodType = z.ZodType<any>> {
877
+ interface RouteMethodOptions<P extends z.ZodType = z.ZodType<any>, Q extends z.ZodType = z.ZodType<any>, B extends z.ZodType = z.ZodType<any>, R extends z.ZodType = z.ZodType<any>, ED extends z.ZodType = z.ZodType<any>> {
228
878
  /** Schema for request/response validation */
229
- schema?: RouteSchema<P, Q, B, R>;
879
+ schema?: RouteSchema<P, Q, B, R, ED>;
230
880
  /** Handler function for the route */
231
881
  handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, B extends z.ZodType ? Infer<B> : unknown, R extends z.ZodType ? Infer<R> : unknown>;
232
882
  /** Middleware to apply to this route */
@@ -238,13 +888,13 @@ interface RouteMethodOptions<P extends z.ZodType = z.ZodType<any>, Q extends z.Z
238
888
  * Route definition mapping HTTP methods to handlers
239
889
  */
240
890
  interface RouteDefinition {
241
- GET?: RouteMethodOptions<any, any, never, any>;
242
- POST?: RouteMethodOptions<any, any, any, any>;
243
- PUT?: RouteMethodOptions<any, any, any, any>;
244
- DELETE?: RouteMethodOptions<any, any, never, any>;
245
- PATCH?: RouteMethodOptions<any, any, any, any>;
246
- HEAD?: RouteMethodOptions<any, any, never, any>;
247
- OPTIONS?: RouteMethodOptions<any, any, never, any>;
891
+ GET?: RouteMethodOptions<any, any, never, any, any>;
892
+ POST?: RouteMethodOptions<any, any, any, any, any>;
893
+ PUT?: RouteMethodOptions<any, any, any, any, any>;
894
+ DELETE?: RouteMethodOptions<any, any, never, any, any>;
895
+ PATCH?: RouteMethodOptions<any, any, any, any, any>;
896
+ HEAD?: RouteMethodOptions<any, any, never, any, any>;
897
+ OPTIONS?: RouteMethodOptions<any, any, never, any, any>;
248
898
  }
249
899
  /**
250
900
  * Route object with path
@@ -397,279 +1047,209 @@ interface StandardErrorResponse {
397
1047
  error: string;
398
1048
  message: string;
399
1049
  }
1050
+ interface FileCache {
1051
+ routes: Route[];
1052
+ timestamp: number;
1053
+ hash: string;
1054
+ }
1055
+ interface ReloadMetrics {
1056
+ fileChanges: number;
1057
+ totalReloadTime: number;
1058
+ averageReloadTime: number;
1059
+ slowReloads: Array<{
1060
+ file: string;
1061
+ time: number;
1062
+ }>;
1063
+ }
1064
+ interface WatchOptions {
1065
+ debounceMs?: number;
1066
+ /** Directories to ignore */
1067
+ ignore?: string[];
1068
+ /** Callback for new routes */
1069
+ onRouteAdded?: (filePath: string, routes: Route[]) => void;
1070
+ /** Callback for changed routes */
1071
+ onRouteChanged?: (filePath: string, routes: Route[]) => void;
1072
+ /** Callback for removed routes */
1073
+ onRouteRemoved?: (filePath: string, routes: Route[]) => void;
1074
+ /** Callback for errors */
1075
+ onError?: (error: Error) => void;
1076
+ }
1077
+ interface RouteRegistry {
1078
+ routesByPath: Map<string, Route>;
1079
+ routesByFile: Map<string, Set<string>>;
1080
+ pathToFile: Map<string, string>;
1081
+ }
1082
+ interface FindRouteFilesOptions {
1083
+ /** Directories to ignore */
1084
+ ignore?: string[] | undefined;
1085
+ }
400
1086
  /**
401
1087
  * GET route creator - no body schema needed
1088
+ * FIXED: Default type parameters to never instead of z.ZodType<any>
402
1089
  */
403
- type CreateGetRoute = <P extends z.ZodType = z.ZodType<any>, Q extends z.ZodType = z.ZodType<any>, R extends z.ZodType = z.ZodType<any>>(config: {
1090
+ type CreateGetRoute = <P = never, // Changed from z.ZodType<any>
1091
+ Q = never, // Changed from z.ZodType<any>
1092
+ R = never>(config: {
404
1093
  schema?: {
405
- params?: P;
406
- query?: Q;
407
- response?: R;
1094
+ params?: P extends never ? never : P;
1095
+ query?: Q extends never ? never : Q;
1096
+ response?: R extends never ? never : R;
408
1097
  };
409
- handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, never, R extends z.ZodType ? Infer<R> : unknown>;
1098
+ handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, never, [
1099
+ R
1100
+ ] extends [never] ? void : R extends z.ZodType ? Infer<R> : void>;
410
1101
  middleware?: Middleware[];
411
1102
  options?: Record<string, unknown>;
412
1103
  }) => {
413
- GET: RouteMethodOptions<P, Q, never, R>;
1104
+ GET: RouteMethodOptions<P extends never ? never : P extends z.ZodType ? P : never, Q extends never ? never : Q extends z.ZodType ? Q : never, never, // GET never has body
1105
+ R extends never ? never : R extends z.ZodType ? R : never>;
414
1106
  path: string;
415
1107
  };
416
1108
  /**
417
1109
  * POST route creator - includes body schema
1110
+ * FIXED: Default type parameters to never
418
1111
  */
419
- type CreatePostRoute = <P extends z.ZodType = z.ZodType<any>, Q extends z.ZodType = z.ZodType<any>, B extends z.ZodType = z.ZodType<any>, R extends z.ZodType = z.ZodType<any>>(config: {
1112
+ type CreatePostRoute = <P = never, Q = never, B = never, R = never>(config: {
420
1113
  schema?: {
421
- params?: P;
422
- query?: Q;
423
- body?: B;
424
- response?: R;
1114
+ params?: P extends never ? never : P;
1115
+ query?: Q extends never ? never : Q;
1116
+ body?: B extends never ? never : B;
1117
+ response?: R extends never ? never : R;
425
1118
  };
426
- handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, B extends z.ZodType ? Infer<B> : unknown, R extends z.ZodType ? Infer<R> : unknown>;
1119
+ handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, B extends z.ZodType ? Infer<B> : unknown, [
1120
+ R
1121
+ ] extends [never] ? void : R extends z.ZodType ? Infer<R> : void>;
427
1122
  middleware?: Middleware[];
428
1123
  options?: Record<string, unknown>;
429
1124
  }) => {
430
- POST: RouteMethodOptions<P, Q, B, R>;
1125
+ POST: RouteMethodOptions<P extends never ? never : P extends z.ZodType ? P : never, Q extends never ? never : Q extends z.ZodType ? Q : never, B extends never ? never : B extends z.ZodType ? B : never, R extends never ? never : R extends z.ZodType ? R : never>;
431
1126
  path: string;
432
1127
  };
433
1128
  /**
434
1129
  * PUT route creator - includes body schema
1130
+ * FIXED: Default type parameters to never
435
1131
  */
436
- type CreatePutRoute = <P extends z.ZodType = z.ZodType<any>, Q extends z.ZodType = z.ZodType<any>, B extends z.ZodType = z.ZodType<any>, R extends z.ZodType = z.ZodType<any>>(config: {
1132
+ type CreatePutRoute = <P = never, Q = never, B = never, R = never>(config: {
437
1133
  schema?: {
438
- params?: P;
439
- query?: Q;
440
- body?: B;
441
- response?: R;
1134
+ params?: P extends never ? never : P;
1135
+ query?: Q extends never ? never : Q;
1136
+ body?: B extends never ? never : B;
1137
+ response?: R extends never ? never : R;
442
1138
  };
443
- handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, B extends z.ZodType ? Infer<B> : unknown, R extends z.ZodType ? Infer<R> : unknown>;
1139
+ handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, B extends z.ZodType ? Infer<B> : unknown, [
1140
+ R
1141
+ ] extends [never] ? void : R extends z.ZodType ? Infer<R> : void>;
444
1142
  middleware?: Middleware[];
445
1143
  options?: Record<string, unknown>;
446
1144
  }) => {
447
- PUT: RouteMethodOptions<P, Q, B, R>;
1145
+ PUT: RouteMethodOptions<P extends never ? never : P extends z.ZodType ? P : never, Q extends never ? never : Q extends z.ZodType ? Q : never, B extends never ? never : B extends z.ZodType ? B : never, R extends never ? never : R extends z.ZodType ? R : never>;
448
1146
  path: string;
449
1147
  };
450
1148
  /**
451
1149
  * DELETE route creator - typically no body
1150
+ * FIXED: Default type parameters to never
452
1151
  */
453
- type CreateDeleteRoute = <P extends z.ZodType = z.ZodType<any>, Q extends z.ZodType = z.ZodType<any>, R extends z.ZodType = z.ZodType<any>>(config: {
1152
+ type CreateDeleteRoute = <P = never, Q = never, R = never>(config: {
454
1153
  schema?: {
455
- params?: P;
456
- query?: Q;
457
- response?: R;
1154
+ params?: P extends never ? never : P;
1155
+ query?: Q extends never ? never : Q;
1156
+ response?: R extends never ? never : R;
458
1157
  };
459
- handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, never, R extends z.ZodType ? Infer<R> : unknown>;
1158
+ handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, never, [
1159
+ R
1160
+ ] extends [never] ? void : R extends z.ZodType ? Infer<R> : void>;
460
1161
  middleware?: Middleware[];
461
1162
  options?: Record<string, unknown>;
462
1163
  }) => {
463
- DELETE: RouteMethodOptions<P, Q, never, R>;
1164
+ DELETE: RouteMethodOptions<P extends never ? never : P extends z.ZodType ? P : never, Q extends never ? never : Q extends z.ZodType ? Q : never, never, // DELETE never has body
1165
+ R extends never ? never : R extends z.ZodType ? R : never>;
464
1166
  path: string;
465
1167
  };
466
1168
  /**
467
1169
  * PATCH route creator - includes body schema
1170
+ * FIXED: Default type parameters to never
468
1171
  */
469
- type CreatePatchRoute = <P extends z.ZodType = z.ZodType<any>, Q extends z.ZodType = z.ZodType<any>, B extends z.ZodType = z.ZodType<any>, R extends z.ZodType = z.ZodType<any>>(config: {
1172
+ type CreatePatchRoute = <P = never, Q = never, B = never, R = never>(config: {
470
1173
  schema?: {
471
- params?: P;
472
- query?: Q;
473
- body?: B;
474
- response?: R;
1174
+ params?: P extends never ? never : P;
1175
+ query?: Q extends never ? never : Q;
1176
+ body?: B extends never ? never : B;
1177
+ response?: R extends never ? never : R;
475
1178
  };
476
- handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, B extends z.ZodType ? Infer<B> : unknown, R extends z.ZodType ? Infer<R> : unknown>;
1179
+ handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, B extends z.ZodType ? Infer<B> : unknown, [
1180
+ R
1181
+ ] extends [never] ? void : R extends z.ZodType ? Infer<R> : void>;
477
1182
  middleware?: Middleware[];
478
1183
  options?: Record<string, unknown>;
479
1184
  }) => {
480
- PATCH: RouteMethodOptions<P, Q, B, R>;
1185
+ PATCH: RouteMethodOptions<P extends never ? never : P extends z.ZodType ? P : never, Q extends never ? never : Q extends z.ZodType ? Q : never, B extends never ? never : B extends z.ZodType ? B : never, R extends never ? never : R extends z.ZodType ? R : never>;
481
1186
  path: string;
482
1187
  };
483
1188
  /**
484
1189
  * HEAD route creator - no body schema needed (same as GET)
1190
+ * FIXED: Default type parameters to never
485
1191
  */
486
- type CreateHeadRoute = <P extends z.ZodType = z.ZodType<any>, Q extends z.ZodType = z.ZodType<any>, R extends z.ZodType = z.ZodType<any>>(config: {
1192
+ type CreateHeadRoute = <P = never, Q = never, R = never>(config: {
487
1193
  schema?: {
488
- params?: P;
489
- query?: Q;
490
- response?: R;
1194
+ params?: P extends never ? never : P;
1195
+ query?: Q extends never ? never : Q;
1196
+ response?: R extends never ? never : R;
491
1197
  };
492
- handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, never, R extends z.ZodType ? Infer<R> : unknown>;
1198
+ handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, never, [
1199
+ R
1200
+ ] extends [never] ? void : R extends z.ZodType ? Infer<R> : void>;
493
1201
  middleware?: Middleware[];
494
1202
  options?: Record<string, unknown>;
495
1203
  }) => {
496
- HEAD: RouteMethodOptions<P, Q, never, R>;
1204
+ HEAD: RouteMethodOptions<P extends never ? never : P extends z.ZodType ? P : never, Q extends never ? never : Q extends z.ZodType ? Q : never, never, // HEAD never has body
1205
+ R extends never ? never : R extends z.ZodType ? R : never>;
497
1206
  path: string;
498
1207
  };
499
1208
  /**
500
1209
  * OPTIONS route creator - typically no body or response schema
1210
+ * FIXED: Default type parameters to never
501
1211
  */
502
- type CreateOptionsRoute = <P extends z.ZodType = z.ZodType<any>, Q extends z.ZodType = z.ZodType<any>, R extends z.ZodType = z.ZodType<any>>(config: {
1212
+ type CreateOptionsRoute = <P = never, Q = never, R = never>(config: {
503
1213
  schema?: {
504
- params?: P;
505
- query?: Q;
506
- response?: R;
1214
+ params?: P extends never ? never : P;
1215
+ query?: Q extends never ? never : Q;
1216
+ response?: R extends never ? never : R;
507
1217
  };
508
- handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, never, R extends z.ZodType ? Infer<R> : unknown>;
1218
+ handler: RouteHandler<P extends z.ZodType ? Infer<P> : Record<string, string>, Q extends z.ZodType ? Infer<Q> : QueryParams, never, [
1219
+ R
1220
+ ] extends [never] ? void : R extends z.ZodType ? Infer<R> : void>;
509
1221
  middleware?: Middleware[];
510
1222
  options?: Record<string, unknown>;
511
1223
  }) => {
512
- OPTIONS: RouteMethodOptions<P, Q, never, R>;
1224
+ OPTIONS: RouteMethodOptions<P extends never ? never : P extends z.ZodType ? P : never, Q extends never ? never : Q extends z.ZodType ? Q : never, never, // OPTIONS never has body
1225
+ R extends never ? never : R extends z.ZodType ? R : never>;
513
1226
  path: string;
514
1227
  };
515
- interface FileCache {
516
- routes: Route[];
517
- timestamp: number;
518
- hash: string;
1228
+
1229
+ /**
1230
+ * Compose multiple middleware functions into a single middleware function
1231
+ */
1232
+ declare function compose(middlewareStack: Middleware[]): MiddlewareFunction;
1233
+
1234
+ /**
1235
+ * Create a middleware
1236
+ */
1237
+ declare function create$2(handlerOrOptions: MiddlewareFunction | MiddlewareOptions): Middleware;
1238
+
1239
+ /**
1240
+ * BlaizeJS Server Module
1241
+ *
1242
+ * Provides the core HTTP/2 server implementation with HTTP/1.1 fallback.
1243
+ */
1244
+
1245
+ interface Http2Options {
1246
+ enabled?: boolean | undefined;
1247
+ keyFile?: string | undefined;
1248
+ certFile?: string | undefined;
519
1249
  }
520
- interface ReloadMetrics {
521
- fileChanges: number;
522
- totalReloadTime: number;
523
- averageReloadTime: number;
524
- slowReloads: Array<{
525
- file: string;
526
- time: number;
527
- }>;
528
- }
529
- interface WatchOptions {
530
- debounceMs?: number;
531
- /** Directories to ignore */
532
- ignore?: string[];
533
- /** Callback for new routes */
534
- onRouteAdded?: (filePath: string, routes: Route[]) => void;
535
- /** Callback for changed routes */
536
- onRouteChanged?: (filePath: string, routes: Route[]) => void;
537
- /** Callback for removed routes */
538
- onRouteRemoved?: (filePath: string, routes: Route[]) => void;
539
- /** Callback for errors */
540
- onError?: (error: Error) => void;
541
- }
542
- interface RouteRegistry {
543
- routesByPath: Map<string, Route>;
544
- routesByFile: Map<string, Set<string>>;
545
- pathToFile: Map<string, string>;
546
- }
547
-
548
- type ExtractParams<T> = T extends RouteMethodOptions<infer P, any, any, any> ? P extends z.ZodType ? Infer<P> : Record<string, string> : never;
549
- type ExtractQuery<T> = T extends RouteMethodOptions<any, infer Q, any, any> ? Q extends z.ZodType ? Infer<Q> : Record<string, string | string[] | undefined> : never;
550
- type ExtractBody<T> = T extends RouteMethodOptions<any, any, infer B, any> ? B extends z.ZodType ? Infer<B> : unknown : never;
551
- type ExtractResponse<T> = T extends RouteMethodOptions<any, any, any, infer R> ? R extends z.ZodType ? Infer<R> : unknown : never;
552
- type ExtractMethod<T> = T extends {
553
- GET: any;
554
- } ? 'GET' : T extends {
555
- POST: any;
556
- } ? 'POST' : T extends {
557
- PUT: any;
558
- } ? 'PUT' : T extends {
559
- DELETE: any;
560
- } ? 'DELETE' : T extends {
561
- PATCH: any;
562
- } ? 'PATCH' : T extends {
563
- HEAD: any;
564
- } ? 'HEAD' : T extends {
565
- OPTIONS: any;
566
- } ? 'OPTIONS' : never;
567
- type BuildRoutesRegistry<TRoutes extends Record<string, any>> = {
568
- [Method in ExtractMethod<TRoutes[keyof TRoutes]> as `$${Lowercase<Method>}`]: {
569
- [K in keyof TRoutes as ExtractMethod<TRoutes[K]> extends Method ? K : never]: TRoutes[K];
570
- };
571
- };
572
- type GetRouteMethod<TRoute> = TRoute extends {
573
- path: string;
574
- } ? Omit<TRoute, 'path'>[keyof Omit<TRoute, 'path'>] : never;
575
- type CreateClientMethod<TRoute> = GetRouteMethod<TRoute> extends RouteMethodOptions<any, any, any, any> ? (args?: {
576
- params?: ExtractParams<GetRouteMethod<TRoute>>;
577
- query?: ExtractQuery<GetRouteMethod<TRoute>>;
578
- body?: ExtractBody<GetRouteMethod<TRoute>>;
579
- }) => Promise<ExtractResponse<GetRouteMethod<TRoute>>> : never;
580
- type CreateClient<TRoutes extends Record<string, Record<string, any>>> = {
581
- [Method in keyof TRoutes]: {
582
- [RouteName in keyof TRoutes[Method]]: CreateClientMethod<TRoutes[Method][RouteName]>;
583
- };
584
- };
585
- interface ClientConfig {
586
- baseUrl: string;
587
- defaultHeaders?: Record<string, string>;
588
- timeout?: number;
589
- }
590
- interface RequestArgs {
591
- params?: Record<string, string>;
592
- query?: Record<string, any>;
593
- body?: unknown;
594
- }
595
- interface RequestOptions {
596
- method: string;
597
- url: string;
598
- headers: Record<string, string>;
599
- body?: string;
600
- timeout: number;
601
- }
602
-
603
- /**
604
- * BlaizeJS Plugin Module
605
- *
606
- * Provides the plugin system for extending framework functionality.
607
- */
608
-
609
- /**
610
- * Plugin options
611
- */
612
- interface PluginOptions<_T = any> {
613
- /** Plugin configuration */
614
- [key: string]: any;
615
- }
616
- /**
617
- * Plugin lifecycle hooks
618
- */
619
- interface PluginHooks {
620
- /** Called when the plugin is registered */
621
- register: (app: Server) => void | Promise<void>;
622
- /** Called when the server is initialized */
623
- initialize?: (app?: Server) => void | Promise<void>;
624
- /** Called when the server is terminated */
625
- terminate?: (app?: Server) => void | Promise<void>;
626
- /** Called when the server starts */
627
- onServerStart?: (server: any) => void | Promise<void>;
628
- /** Called when the server stops */
629
- onServerStop?: (server: any) => void | Promise<void>;
630
- }
631
- /**
632
- * Plugin interface
633
- */
634
- interface Plugin extends PluginHooks {
635
- /** Plugin name */
636
- name: string;
637
- /** Plugin version */
638
- version: string;
639
- }
640
- /**
641
- * Plugin factory function
642
- */
643
- type PluginFactory<T = any> = (options?: T) => Plugin;
644
- interface PluginLifecycleManager {
645
- initializePlugins(server: Server): Promise<void>;
646
- terminatePlugins(server: Server): Promise<void>;
647
- onServerStart(server: Server, httpServer: any): Promise<void>;
648
- onServerStop(server: Server, httpServer: any): Promise<void>;
649
- }
650
- interface PluginLifecycleOptions {
651
- /** Continue initialization even if a plugin fails */
652
- continueOnError?: boolean;
653
- /** Log plugin lifecycle events */
654
- debug?: boolean;
655
- /** Custom error handler for plugin failures */
656
- onError?: (plugin: Plugin, phase: string, error: Error) => void;
657
- }
658
-
659
- /**
660
- * BlaizeJS Server Module
661
- *
662
- * Provides the core HTTP/2 server implementation with HTTP/1.1 fallback.
663
- */
664
-
665
- interface Http2Options {
666
- enabled?: boolean | undefined;
667
- keyFile?: string | undefined;
668
- certFile?: string | undefined;
669
- }
670
- interface StartOptions {
671
- port?: number;
672
- host?: string;
1250
+ interface StartOptions {
1251
+ port?: number;
1252
+ host?: string;
673
1253
  }
674
1254
  interface StopOptions {
675
1255
  timeout?: number;
@@ -760,6 +1340,469 @@ interface Server {
760
1340
  }
761
1341
  type RequestHandler = (req: http.IncomingMessage | http2.Http2ServerRequest, res: http.ServerResponse | http2.Http2ServerResponse) => Promise<void>;
762
1342
 
1343
+ /**
1344
+ * BlaizeJS Plugin Module
1345
+ *
1346
+ * Provides the plugin system for extending framework functionality.
1347
+ */
1348
+
1349
+ /**
1350
+ * Plugin options
1351
+ */
1352
+ interface PluginOptions<_T = any> {
1353
+ /** Plugin configuration */
1354
+ [key: string]: any;
1355
+ }
1356
+ /**
1357
+ * Plugin lifecycle hooks
1358
+ */
1359
+ interface PluginHooks {
1360
+ /** Called when the plugin is registered */
1361
+ register: (app: Server) => void | Promise<void>;
1362
+ /** Called when the server is initialized */
1363
+ initialize?: (app?: Server) => void | Promise<void>;
1364
+ /** Called when the server is terminated */
1365
+ terminate?: (app?: Server) => void | Promise<void>;
1366
+ /** Called when the server starts */
1367
+ onServerStart?: (server: any) => void | Promise<void>;
1368
+ /** Called when the server stops */
1369
+ onServerStop?: (server: any) => void | Promise<void>;
1370
+ }
1371
+ /**
1372
+ * Plugin interface
1373
+ */
1374
+ interface Plugin extends PluginHooks {
1375
+ /** Plugin name */
1376
+ name: string;
1377
+ /** Plugin version */
1378
+ version: string;
1379
+ }
1380
+ /**
1381
+ * Plugin factory function
1382
+ */
1383
+ type PluginFactory<T = any> = (options?: T) => Plugin;
1384
+ interface PluginLifecycleManager {
1385
+ initializePlugins(server: Server): Promise<void>;
1386
+ terminatePlugins(server: Server): Promise<void>;
1387
+ onServerStart(server: Server, httpServer: any): Promise<void>;
1388
+ onServerStop(server: Server, httpServer: any): Promise<void>;
1389
+ }
1390
+ interface PluginLifecycleOptions {
1391
+ /** Continue initialization even if a plugin fails */
1392
+ continueOnError?: boolean;
1393
+ /** Log plugin lifecycle events */
1394
+ debug?: boolean;
1395
+ /** Custom error handler for plugin failures */
1396
+ onError?: (plugin: Plugin, phase: string, error: Error) => void;
1397
+ }
1398
+
1399
+ /**
1400
+ * Create a plugin with the given name, version, and setup function
1401
+ */
1402
+ declare function create$1<T = any>(name: string, version: string, setup: (app: Server, options: T) => void | Partial<PluginHooks> | Promise<void> | Promise<Partial<PluginHooks>>, defaultOptions?: Partial<T>): PluginFactory<T>;
1403
+
1404
+ /**
1405
+ * Create a GET route
1406
+ * SIMPLER FIX: Just pass the config through, TypeScript will handle the types
1407
+ */
1408
+ declare const createGetRoute: CreateGetRoute;
1409
+ /**
1410
+ * Create a POST route
1411
+ */
1412
+ declare const createPostRoute: CreatePostRoute;
1413
+ /**
1414
+ * Create a PUT route
1415
+ */
1416
+ declare const createPutRoute: CreatePutRoute;
1417
+ /**
1418
+ * Create a DELETE route
1419
+ */
1420
+ declare const createDeleteRoute: CreateDeleteRoute;
1421
+ /**
1422
+ * Create a PATCH route
1423
+ */
1424
+ declare const createPatchRoute: CreatePatchRoute;
1425
+ /**
1426
+ * Create a HEAD route (same signature as GET - no body)
1427
+ */
1428
+ declare const createHeadRoute: CreateHeadRoute;
1429
+ /**
1430
+ * Create an OPTIONS route (same signature as GET - no body)
1431
+ */
1432
+ declare const createOptionsRoute: CreateOptionsRoute;
1433
+
1434
+ /**
1435
+ * Creates a BlaizeJS server instance
1436
+ */
1437
+ declare function create(options?: ServerOptionsInput): Server;
1438
+
1439
+ type ExtractMethod<T> = T extends {
1440
+ GET: any;
1441
+ } ? 'GET' : T extends {
1442
+ POST: any;
1443
+ } ? 'POST' : T extends {
1444
+ PUT: any;
1445
+ } ? 'PUT' : T extends {
1446
+ DELETE: any;
1447
+ } ? 'DELETE' : T extends {
1448
+ PATCH: any;
1449
+ } ? 'PATCH' : T extends {
1450
+ HEAD: any;
1451
+ } ? 'HEAD' : T extends {
1452
+ OPTIONS: any;
1453
+ } ? 'OPTIONS' : never;
1454
+ type BuildRoutesRegistry<TRoutes extends Record<string, any>> = {
1455
+ [Method in ExtractMethod<TRoutes[keyof TRoutes]> as `$${Lowercase<Method>}`]: {
1456
+ [K in keyof TRoutes as ExtractMethod<TRoutes[K]> extends Method ? K : never]: TRoutes[K];
1457
+ };
1458
+ };
1459
+ type GetRouteMethodOptions<TRoute> = TRoute extends {
1460
+ GET: infer M;
1461
+ } ? M : TRoute extends {
1462
+ POST: infer M;
1463
+ } ? M : TRoute extends {
1464
+ PUT: infer M;
1465
+ } ? M : TRoute extends {
1466
+ DELETE: infer M;
1467
+ } ? M : TRoute extends {
1468
+ PATCH: infer M;
1469
+ } ? M : TRoute extends {
1470
+ HEAD: infer M;
1471
+ } ? M : TRoute extends {
1472
+ OPTIONS: infer M;
1473
+ } ? M : never;
1474
+ type IsNever<T> = [T] extends [never] ? true : false;
1475
+ type BuildArgsObject<P, Q, B> = (IsNever<P> extends true ? {} : {
1476
+ params: Infer<P>;
1477
+ }) & (IsNever<Q> extends true ? {} : {
1478
+ query: Infer<Q>;
1479
+ }) & (IsNever<B> extends true ? {} : {
1480
+ body: Infer<B>;
1481
+ });
1482
+ type IsEmptyObject<T> = keyof T extends never ? true : false;
1483
+ type BuildArgs<P, Q, B> = IsEmptyObject<BuildArgsObject<P, Q, B>> extends true ? void : BuildArgsObject<P, Q, B>;
1484
+ type CreateClientMethod<TRoute> = GetRouteMethodOptions<TRoute> extends RouteMethodOptions<infer P, infer Q, infer B, infer R> ? BuildArgs<P, Q, B> extends void ? () => Promise<R extends z.ZodType ? Infer<R> : unknown> : (args: BuildArgs<P, Q, B>) => Promise<R extends z.ZodType ? Infer<R> : unknown> : never;
1485
+ type CreateClient<TRoutes extends Record<string, Record<string, any>>> = {
1486
+ [Method in keyof TRoutes]: {
1487
+ [RouteName in keyof TRoutes[Method]]: CreateClientMethod<TRoutes[Method][RouteName]>;
1488
+ };
1489
+ };
1490
+ interface ClientConfig {
1491
+ baseUrl: string;
1492
+ defaultHeaders?: Record<string, string>;
1493
+ timeout?: number;
1494
+ }
1495
+ interface InternalRequestArgs {
1496
+ params?: Record<string, any>;
1497
+ query?: Record<string, any>;
1498
+ body?: any;
1499
+ }
1500
+ interface RequestOptions {
1501
+ method: string;
1502
+ url: string;
1503
+ headers: Record<string, string>;
1504
+ body?: string;
1505
+ timeout: number;
1506
+ }
1507
+
1508
+ /**
1509
+ * ValidationError class for request validation failures
1510
+ *
1511
+ * This error is thrown when request validation fails (params, query, body, or response).
1512
+ * It provides structured information about which fields failed validation and why.
1513
+ */
1514
+
1515
+ /**
1516
+ * Error thrown when request validation fails
1517
+ *
1518
+ * Automatically sets HTTP status to 400 and provides structured
1519
+ * validation error information for better client debugging.
1520
+ *
1521
+ * @example Basic usage:
1522
+ * ```typescript
1523
+ * throw new ValidationError('Email is required');
1524
+ * ```
1525
+ *
1526
+ * @example With detailed field information:
1527
+ * ```typescript
1528
+ * throw new ValidationError('Validation failed', {
1529
+ * fields: [
1530
+ * {
1531
+ * field: 'email',
1532
+ * messages: ['Email is required', 'Email must be valid'],
1533
+ * rejectedValue: '',
1534
+ * expectedType: 'string'
1535
+ * }
1536
+ * ],
1537
+ * errorCount: 1,
1538
+ * section: 'body'
1539
+ * });
1540
+ * ```
1541
+ */
1542
+ declare class ValidationError extends BlaizeError<ValidationErrorDetails> {
1543
+ /**
1544
+ * Creates a new ValidationError instance
1545
+ *
1546
+ * @param title - Human-readable error message
1547
+ * @param details - Optional structured validation details
1548
+ * @param correlationId - Optional correlation ID (uses current context if not provided)
1549
+ */
1550
+ constructor(title: string, details?: ValidationErrorDetails | undefined, correlationId?: string | undefined);
1551
+ }
1552
+
1553
+ /**
1554
+ * NotFoundError class for resource not found errors
1555
+ *
1556
+ * This error is thrown when a requested resource cannot be found.
1557
+ * It provides context about what resource was being looked for and how.
1558
+ */
1559
+
1560
+ /**
1561
+ * Error thrown when a requested resource cannot be found
1562
+ *
1563
+ * Automatically sets HTTP status to 404 and provides context
1564
+ * about the missing resource for better debugging and user experience.
1565
+ *
1566
+ * @example Basic usage:
1567
+ * ```typescript
1568
+ * throw new NotFoundError('User not found');
1569
+ * ```
1570
+ *
1571
+ * @example With resource context:
1572
+ * ```typescript
1573
+ * throw new NotFoundError('User not found', {
1574
+ * resourceType: 'User',
1575
+ * resourceId: 'user-123',
1576
+ * suggestion: 'Check if the user ID is correct'
1577
+ * });
1578
+ * ```
1579
+ *
1580
+ * @example API endpoint not found:
1581
+ * ```typescript
1582
+ * throw new NotFoundError('Endpoint not found', {
1583
+ * path: '/api/v1/unknown',
1584
+ * method: 'GET',
1585
+ * suggestion: 'Check the API documentation'
1586
+ * });
1587
+ * ```
1588
+ */
1589
+ declare class NotFoundError extends BlaizeError<NotFoundErrorDetails> {
1590
+ /**
1591
+ * Creates a new NotFoundError instance
1592
+ *
1593
+ * @param title - Human-readable error message
1594
+ * @param details - Optional context about the missing resource
1595
+ * @param correlationId - Optional correlation ID (uses current context if not provided)
1596
+ */
1597
+ constructor(title: string, details?: NotFoundErrorDetails | undefined, correlationId?: string | undefined);
1598
+ }
1599
+
1600
+ /**
1601
+ * UnauthorizedError class for authentication failures
1602
+ *
1603
+ * This error is thrown when authentication is required or has failed.
1604
+ * It provides context about authentication requirements and failure reasons.
1605
+ */
1606
+
1607
+ /**
1608
+ * Error thrown when authentication is required or has failed
1609
+ *
1610
+ * Automatically sets HTTP status to 401 and provides authentication context.
1611
+ *
1612
+ * @example Basic usage:
1613
+ * ```typescript
1614
+ * throw new UnauthorizedError('Authentication required');
1615
+ * ```
1616
+ *
1617
+ * @example With authentication details:
1618
+ * ```typescript
1619
+ * throw new UnauthorizedError('Token expired', {
1620
+ * reason: 'expired_token',
1621
+ * authScheme: 'Bearer',
1622
+ * loginUrl: '/auth/login'
1623
+ * });
1624
+ * ```
1625
+ */
1626
+ declare class UnauthorizedError extends BlaizeError<UnauthorizedErrorDetails> {
1627
+ /**
1628
+ * Creates a new UnauthorizedError instance
1629
+ *
1630
+ * @param title - Human-readable error message
1631
+ * @param details - Optional authentication context
1632
+ * @param correlationId - Optional correlation ID (uses current context if not provided)
1633
+ */
1634
+ constructor(title: string, details?: UnauthorizedErrorDetails | undefined, correlationId?: string | undefined);
1635
+ }
1636
+
1637
+ /**
1638
+ * ForbiddenError class for authorization failures
1639
+ *
1640
+ * This error is thrown when a user lacks permission to access a resource.
1641
+ * It provides context about required permissions and access control.
1642
+ */
1643
+
1644
+ /**
1645
+ * Error thrown when user lacks permission to access a resource
1646
+ *
1647
+ * Automatically sets HTTP status to 403 and provides permission context.
1648
+ *
1649
+ * @example Basic usage:
1650
+ * ```typescript
1651
+ * throw new ForbiddenError('Access denied');
1652
+ * ```
1653
+ *
1654
+ * @example With permission details:
1655
+ * ```typescript
1656
+ * throw new ForbiddenError('Insufficient permissions', {
1657
+ * requiredPermission: 'admin:users:delete',
1658
+ * userPermissions: ['admin:users:read'],
1659
+ * resource: 'user-123',
1660
+ * action: 'delete'
1661
+ * });
1662
+ * ```
1663
+ */
1664
+ declare class ForbiddenError extends BlaizeError<ForbiddenErrorDetails> {
1665
+ /**
1666
+ * Creates a new ForbiddenError instance
1667
+ *
1668
+ * @param title - Human-readable error message
1669
+ * @param details - Optional permission context
1670
+ * @param correlationId - Optional correlation ID (uses current context if not provided)
1671
+ */
1672
+ constructor(title: string, details?: ForbiddenErrorDetails | undefined, correlationId?: string | undefined);
1673
+ }
1674
+
1675
+ /**
1676
+ * ConflictError class for resource conflicts
1677
+ *
1678
+ * This error is thrown when a resource conflict occurs, such as duplicate keys,
1679
+ * version mismatches, or concurrent modifications.
1680
+ */
1681
+
1682
+ /**
1683
+ * Error thrown when a resource conflict occurs
1684
+ *
1685
+ * Automatically sets HTTP status to 409 and provides conflict context.
1686
+ *
1687
+ * @example Basic usage:
1688
+ * ```typescript
1689
+ * throw new ConflictError('Email already exists');
1690
+ * ```
1691
+ *
1692
+ * @example With conflict details:
1693
+ * ```typescript
1694
+ * throw new ConflictError('Version conflict', {
1695
+ * conflictType: 'version_mismatch',
1696
+ * currentVersion: '2',
1697
+ * expectedVersion: '1',
1698
+ * resolution: 'Fetch the latest version and retry'
1699
+ * });
1700
+ * ```
1701
+ */
1702
+ declare class ConflictError extends BlaizeError<ConflictErrorDetails> {
1703
+ /**
1704
+ * Creates a new ConflictError instance
1705
+ *
1706
+ * @param title - Human-readable error message
1707
+ * @param details - Optional conflict context
1708
+ * @param correlationId - Optional correlation ID (uses current context if not provided)
1709
+ */
1710
+ constructor(title: string, details?: ConflictErrorDetails | undefined, correlationId?: string | undefined);
1711
+ }
1712
+
1713
+ /**
1714
+ * RateLimitError class for rate limiting violations
1715
+ *
1716
+ * This error is thrown when rate limits are exceeded.
1717
+ * It provides context about the rate limit and when requests can resume.
1718
+ */
1719
+
1720
+ /**
1721
+ * Error thrown when rate limits are exceeded
1722
+ *
1723
+ * Automatically sets HTTP status to 429 and provides rate limit context.
1724
+ *
1725
+ * @example Basic usage:
1726
+ * ```typescript
1727
+ * throw new RateLimitError('Too many requests');
1728
+ * ```
1729
+ *
1730
+ * @example With rate limit details:
1731
+ * ```typescript
1732
+ * throw new RateLimitError('Rate limit exceeded', {
1733
+ * limit: 100,
1734
+ * remaining: 0,
1735
+ * retryAfter: 3600,
1736
+ * window: 'hour',
1737
+ * identifier: 'user-123'
1738
+ * });
1739
+ * ```
1740
+ */
1741
+ declare class RateLimitError extends BlaizeError<RateLimitErrorDetails> {
1742
+ /**
1743
+ * Creates a new RateLimitError instance
1744
+ *
1745
+ * @param title - Human-readable error message
1746
+ * @param details - Optional rate limit context
1747
+ * @param correlationId - Optional correlation ID (uses current context if not provided)
1748
+ */
1749
+ constructor(title: string, details?: RateLimitErrorDetails | undefined, correlationId?: string | undefined);
1750
+ }
1751
+
1752
+ /**
1753
+ * InternalServerError class for server-side errors
1754
+ *
1755
+ * This error is thrown for unexpected server-side errors that are not
1756
+ * the client's fault. It provides debugging context while protecting
1757
+ * sensitive information in production.
1758
+ */
1759
+
1760
+ /**
1761
+ * Error thrown for internal server errors
1762
+ *
1763
+ * Automatically sets HTTP status to 500 and provides debugging context.
1764
+ * Note: In production, sensitive details should be filtered by error boundary.
1765
+ *
1766
+ * @example Basic usage:
1767
+ * ```typescript
1768
+ * throw new InternalServerError('Something went wrong');
1769
+ * ```
1770
+ *
1771
+ * @example With debugging details:
1772
+ * ```typescript
1773
+ * throw new InternalServerError('Database error', {
1774
+ * originalError: error.message,
1775
+ * component: 'user-service',
1776
+ * operation: 'createUser',
1777
+ * retryable: true
1778
+ * });
1779
+ * ```
1780
+ *
1781
+ * @example Wrapping an existing error:
1782
+ * ```typescript
1783
+ * try {
1784
+ * await database.connect();
1785
+ * } catch (error) {
1786
+ * throw new InternalServerError('Database connection failed', {
1787
+ * originalError: error.message,
1788
+ * stackTrace: error.stack,
1789
+ * component: 'database',
1790
+ * retryable: true
1791
+ * });
1792
+ * }
1793
+ * ```
1794
+ */
1795
+ declare class InternalServerError extends BlaizeError<InternalServerErrorDetails> {
1796
+ /**
1797
+ * Creates a new InternalServerError instance
1798
+ *
1799
+ * @param title - Human-readable error message
1800
+ * @param details - Optional debugging context
1801
+ * @param correlationId - Optional correlation ID (uses current context if not provided)
1802
+ */
1803
+ constructor(title: string, details?: InternalServerErrorDetails | undefined, correlationId?: string | undefined);
1804
+ }
1805
+
763
1806
  declare const VERSION = "0.1.0";
764
1807
  declare const ServerAPI: {
765
1808
  createServer: typeof create;
@@ -780,6 +1823,7 @@ declare const MiddlewareAPI: {
780
1823
  declare const PluginsAPI: {
781
1824
  createPlugin: typeof create$1;
782
1825
  };
1826
+
783
1827
  declare const Blaize: {
784
1828
  createServer: typeof create;
785
1829
  createMiddleware: typeof create$2;
@@ -806,4 +1850,4 @@ declare const Blaize: {
806
1850
  VERSION: string;
807
1851
  };
808
1852
 
809
- export { Blaize, type BuildRoutesRegistry, type ClientConfig, type Context, type ContextOptions, type ContextRequest, type ContextResponse, type CreateClient, type CreateContextFn, type CreateDeleteRoute, type CreateGetRoute, type CreateHeadRoute, type CreateOptionsRoute, type CreatePatchRoute, type CreatePostRoute, type CreatePutRoute, type ErrorHandlerOptions, type ExtractBody, type ExtractMethod, type ExtractParams, type ExtractQuery, type ExtractResponse, type FileCache, type GetContextFn, type Http2Options, type HttpMethod, type Infer, type Matcher, type Middleware, MiddlewareAPI, type MiddlewareFunction, type MiddlewareOptions, type NextFunction, type ParsedRoute, type Plugin, type PluginFactory, type PluginHooks, type PluginLifecycleManager, type PluginLifecycleOptions, type PluginOptions, PluginsAPI, type ProcessResponseOptions, type QueryParams, type ReloadMetrics, type RequestArgs, type RequestHandler, type RequestOptions, type RequestParams, type Result, type Route, type RouteDefinition, type RouteEntry, type RouteHandler, type RouteMatch, type RouteMethodOptions, type RouteNode, type RouteOptions, type RouteRegistry, type RouteSchema, type Router, RouterAPI, type RouterOptions, type Server, ServerAPI, type ServerOptions, type ServerOptionsInput, type StandardErrorResponse, type StartOptions, type State, type StopOptions, type StreamOptions, type UnifiedRequest, type UnifiedResponse, type UnknownFunction, VERSION, type WatchOptions, compose, createDeleteRoute, createGetRoute, createHeadRoute, create$2 as createMiddleware, createOptionsRoute, createPatchRoute, create$1 as createPlugin, createPostRoute, createPutRoute, create as createServer, Blaize as default };
1853
+ export { Blaize, BlaizeError, type BlaizeErrorResponse, type BodyParseError, type BuildRoutesRegistry, type ClientConfig, ConflictError, type ConflictErrorDetails, type Context, type ContextOptions, type ContextRequest, type ContextResponse, type CreateClient, type CreateContextFn, type CreateDeleteRoute, type CreateGetRoute, type CreateHeadRoute, type CreateOptionsRoute, type CreatePatchRoute, type CreatePostRoute, type CreatePutRoute, type ErrorHandlerOptions, ErrorSeverity, type ErrorTransformContext, ErrorType, type ExtractMethod, type FileCache, type FindRouteFilesOptions, ForbiddenError, type ForbiddenErrorDetails, type GetContextFn, type Http2Options, type HttpMethod, type Infer, type InternalRequestArgs, InternalServerError, type InternalServerErrorDetails, type Matcher, type Middleware, MiddlewareAPI, type MiddlewareFunction, type MiddlewareOptions, type MultipartData, type MultipartError, type MultipartLimits, type NetworkErrorContext, type NextFunction, NotFoundError, type NotFoundErrorDetails, type ParseErrorContext, type ParseOptions, type ParseResult, type ParsedRoute, type ParserState, type PayloadTooLargeErrorDetails, type Plugin, type PluginFactory, type PluginHooks, type PluginLifecycleManager, type PluginLifecycleOptions, type PluginOptions, PluginsAPI, type ProcessResponseOptions, type ProcessingConfig, type QueryParams, RateLimitError, type RateLimitErrorDetails, type ReloadMetrics, type RequestHandler, type RequestOptions, type RequestParams, type Result, type Route, type RouteDefinition, type RouteEntry, type RouteHandler, type RouteMatch, type RouteMethodOptions, type RouteNode, type RouteOptions, type RouteRegistry, type RouteSchema, type Router, RouterAPI, type RouterOptions, type Server, ServerAPI, type ServerOptions, type ServerOptionsInput, type StandardErrorResponse, type StartOptions, type State, type StopOptions, type StreamOptions, type TimeoutErrorContext, UnauthorizedError, type UnauthorizedErrorDetails, type UnifiedRequest, type UnifiedResponse, type UnknownFunction, type UnsupportedMediaTypeErrorDetails, type UploadProgress, type UploadedFile, VERSION, type ValidationConfig, ValidationError, type ValidationErrorDetails, type ValidationFieldError, type WatchOptions, compose, createDeleteRoute, createGetRoute, createHeadRoute, create$2 as createMiddleware, createOptionsRoute, createPatchRoute, create$1 as createPlugin, createPostRoute, createPutRoute, create as createServer, Blaize as default, isBodyParseError };