blaizejs 0.3.0 → 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.ts CHANGED
@@ -1047,157 +1047,184 @@ interface StandardErrorResponse {
1047
1047
  error: string;
1048
1048
  message: string;
1049
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
+ }
1050
1086
  /**
1051
1087
  * GET route creator - no body schema needed
1088
+ * FIXED: Default type parameters to never instead of z.ZodType<any>
1052
1089
  */
1053
- 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: {
1054
1093
  schema?: {
1055
- params?: P;
1056
- query?: Q;
1057
- response?: R;
1094
+ params?: P extends never ? never : P;
1095
+ query?: Q extends never ? never : Q;
1096
+ response?: R extends never ? never : R;
1058
1097
  };
1059
- 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>;
1060
1101
  middleware?: Middleware[];
1061
1102
  options?: Record<string, unknown>;
1062
1103
  }) => {
1063
- 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>;
1064
1106
  path: string;
1065
1107
  };
1066
1108
  /**
1067
1109
  * POST route creator - includes body schema
1110
+ * FIXED: Default type parameters to never
1068
1111
  */
1069
- 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: {
1070
1113
  schema?: {
1071
- params?: P;
1072
- query?: Q;
1073
- body?: B;
1074
- 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;
1075
1118
  };
1076
- 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>;
1077
1122
  middleware?: Middleware[];
1078
1123
  options?: Record<string, unknown>;
1079
1124
  }) => {
1080
- 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>;
1081
1126
  path: string;
1082
1127
  };
1083
1128
  /**
1084
1129
  * PUT route creator - includes body schema
1130
+ * FIXED: Default type parameters to never
1085
1131
  */
1086
- 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: {
1087
1133
  schema?: {
1088
- params?: P;
1089
- query?: Q;
1090
- body?: B;
1091
- 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;
1092
1138
  };
1093
- 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>;
1094
1142
  middleware?: Middleware[];
1095
1143
  options?: Record<string, unknown>;
1096
1144
  }) => {
1097
- 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>;
1098
1146
  path: string;
1099
1147
  };
1100
1148
  /**
1101
1149
  * DELETE route creator - typically no body
1150
+ * FIXED: Default type parameters to never
1102
1151
  */
1103
- 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: {
1104
1153
  schema?: {
1105
- params?: P;
1106
- query?: Q;
1107
- response?: R;
1154
+ params?: P extends never ? never : P;
1155
+ query?: Q extends never ? never : Q;
1156
+ response?: R extends never ? never : R;
1108
1157
  };
1109
- 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>;
1110
1161
  middleware?: Middleware[];
1111
1162
  options?: Record<string, unknown>;
1112
1163
  }) => {
1113
- 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>;
1114
1166
  path: string;
1115
1167
  };
1116
1168
  /**
1117
1169
  * PATCH route creator - includes body schema
1170
+ * FIXED: Default type parameters to never
1118
1171
  */
1119
- 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: {
1120
1173
  schema?: {
1121
- params?: P;
1122
- query?: Q;
1123
- body?: B;
1124
- 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;
1125
1178
  };
1126
- 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>;
1127
1182
  middleware?: Middleware[];
1128
1183
  options?: Record<string, unknown>;
1129
1184
  }) => {
1130
- 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>;
1131
1186
  path: string;
1132
1187
  };
1133
1188
  /**
1134
1189
  * HEAD route creator - no body schema needed (same as GET)
1190
+ * FIXED: Default type parameters to never
1135
1191
  */
1136
- 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: {
1137
1193
  schema?: {
1138
- params?: P;
1139
- query?: Q;
1140
- response?: R;
1194
+ params?: P extends never ? never : P;
1195
+ query?: Q extends never ? never : Q;
1196
+ response?: R extends never ? never : R;
1141
1197
  };
1142
- 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>;
1143
1201
  middleware?: Middleware[];
1144
1202
  options?: Record<string, unknown>;
1145
1203
  }) => {
1146
- 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>;
1147
1206
  path: string;
1148
1207
  };
1149
1208
  /**
1150
1209
  * OPTIONS route creator - typically no body or response schema
1210
+ * FIXED: Default type parameters to never
1151
1211
  */
1152
- 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: {
1153
1213
  schema?: {
1154
- params?: P;
1155
- query?: Q;
1156
- response?: R;
1214
+ params?: P extends never ? never : P;
1215
+ query?: Q extends never ? never : Q;
1216
+ response?: R extends never ? never : R;
1157
1217
  };
1158
- 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>;
1159
1221
  middleware?: Middleware[];
1160
1222
  options?: Record<string, unknown>;
1161
1223
  }) => {
1162
- 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>;
1163
1226
  path: string;
1164
1227
  };
1165
- interface FileCache {
1166
- routes: Route[];
1167
- timestamp: number;
1168
- hash: string;
1169
- }
1170
- interface ReloadMetrics {
1171
- fileChanges: number;
1172
- totalReloadTime: number;
1173
- averageReloadTime: number;
1174
- slowReloads: Array<{
1175
- file: string;
1176
- time: number;
1177
- }>;
1178
- }
1179
- interface WatchOptions {
1180
- debounceMs?: number;
1181
- /** Directories to ignore */
1182
- ignore?: string[];
1183
- /** Callback for new routes */
1184
- onRouteAdded?: (filePath: string, routes: Route[]) => void;
1185
- /** Callback for changed routes */
1186
- onRouteChanged?: (filePath: string, routes: Route[]) => void;
1187
- /** Callback for removed routes */
1188
- onRouteRemoved?: (filePath: string, routes: Route[]) => void;
1189
- /** Callback for errors */
1190
- onError?: (error: Error) => void;
1191
- }
1192
- interface RouteRegistry {
1193
- routesByPath: Map<string, Route>;
1194
- routesByFile: Map<string, Set<string>>;
1195
- pathToFile: Map<string, string>;
1196
- }
1197
- interface FindRouteFilesOptions {
1198
- /** Directories to ignore */
1199
- ignore?: string[] | undefined;
1200
- }
1201
1228
 
1202
1229
  /**
1203
1230
  * Compose multiple middleware functions into a single middleware function
@@ -1376,6 +1403,7 @@ declare function create$1<T = any>(name: string, version: string, setup: (app: S
1376
1403
 
1377
1404
  /**
1378
1405
  * Create a GET route
1406
+ * SIMPLER FIX: Just pass the config through, TypeScript will handle the types
1379
1407
  */
1380
1408
  declare const createGetRoute: CreateGetRoute;
1381
1409
  /**
@@ -1408,10 +1436,6 @@ declare const createOptionsRoute: CreateOptionsRoute;
1408
1436
  */
1409
1437
  declare function create(options?: ServerOptionsInput): Server;
1410
1438
 
1411
- type ExtractParams<T> = T extends RouteMethodOptions<infer P, any, any, any> ? P extends z.ZodType ? Infer<P> : Record<string, string> : never;
1412
- type ExtractQuery<T> = T extends RouteMethodOptions<any, infer Q, any, any> ? Q extends z.ZodType ? Infer<Q> : Record<string, string | string[] | undefined> : never;
1413
- type ExtractBody<T> = T extends RouteMethodOptions<any, any, infer B, any> ? B extends z.ZodType ? Infer<B> : unknown : never;
1414
- type ExtractResponse<T> = T extends RouteMethodOptions<any, any, any, infer R> ? R extends z.ZodType ? Infer<R> : unknown : never;
1415
1439
  type ExtractMethod<T> = T extends {
1416
1440
  GET: any;
1417
1441
  } ? 'GET' : T extends {
@@ -1432,14 +1456,32 @@ type BuildRoutesRegistry<TRoutes extends Record<string, any>> = {
1432
1456
  [K in keyof TRoutes as ExtractMethod<TRoutes[K]> extends Method ? K : never]: TRoutes[K];
1433
1457
  };
1434
1458
  };
1435
- type GetRouteMethod<TRoute> = TRoute extends {
1436
- path: string;
1437
- } ? Omit<TRoute, 'path'>[keyof Omit<TRoute, 'path'>] : never;
1438
- type CreateClientMethod<TRoute> = GetRouteMethod<TRoute> extends RouteMethodOptions<any, any, any, any> ? (args?: {
1439
- params?: ExtractParams<GetRouteMethod<TRoute>>;
1440
- query?: ExtractQuery<GetRouteMethod<TRoute>>;
1441
- body?: ExtractBody<GetRouteMethod<TRoute>>;
1442
- }) => Promise<ExtractResponse<GetRouteMethod<TRoute>>> : never;
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;
1443
1485
  type CreateClient<TRoutes extends Record<string, Record<string, any>>> = {
1444
1486
  [Method in keyof TRoutes]: {
1445
1487
  [RouteName in keyof TRoutes[Method]]: CreateClientMethod<TRoutes[Method][RouteName]>;
@@ -1450,10 +1492,10 @@ interface ClientConfig {
1450
1492
  defaultHeaders?: Record<string, string>;
1451
1493
  timeout?: number;
1452
1494
  }
1453
- interface RequestArgs {
1454
- params?: Record<string, string>;
1495
+ interface InternalRequestArgs {
1496
+ params?: Record<string, any>;
1455
1497
  query?: Record<string, any>;
1456
- body?: unknown;
1498
+ body?: any;
1457
1499
  }
1458
1500
  interface RequestOptions {
1459
1501
  method: string;
@@ -1808,4 +1850,4 @@ declare const Blaize: {
1808
1850
  VERSION: string;
1809
1851
  };
1810
1852
 
1811
- 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 ExtractBody, type ExtractMethod, type ExtractParams, type ExtractQuery, type ExtractResponse, type FileCache, type FindRouteFilesOptions, ForbiddenError, type ForbiddenErrorDetails, type GetContextFn, type Http2Options, type HttpMethod, type Infer, 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 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 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 };
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 };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * blaizejs v0.3.0
2
+ * blaizejs v0.3.1
3
3
  * A blazing-fast, TypeScript-first Node.js framework with HTTP/2 support, file-based routing, powerful middleware system, and end-to-end type safety for building modern APIs.
4
4
  *
5
5
  * Copyright (c) 2025 BlaizeJS Contributors
@@ -8,10 +8,10 @@
8
8
 
9
9
  import {
10
10
  InternalServerError
11
- } from "./chunk-QQCQRHXJ.js";
11
+ } from "./chunk-ZZEQFU5V.js";
12
12
  import {
13
13
  ValidationError
14
- } from "./chunk-SRD3AB6T.js";
14
+ } from "./chunk-3A5J5MKL.js";
15
15
  import {
16
16
  BlaizeError,
17
17
  ErrorSeverity,
@@ -20,7 +20,7 @@ import {
20
20
  generateCorrelationId,
21
21
  getCurrentCorrelationId,
22
22
  isBodyParseError
23
- } from "./chunk-TCPQMZ23.js";
23
+ } from "./chunk-SF7ZGOEK.js";
24
24
 
25
25
  // src/middleware/execute.ts
26
26
  function execute(middleware, ctx, next) {
@@ -216,6 +216,7 @@ var createGetRoute = (config2) => {
216
216
  const path6 = getRoutePath();
217
217
  return {
218
218
  GET: config2,
219
+ // Let TypeScript infer the proper types
219
220
  path: path6
220
221
  };
221
222
  };
@@ -224,6 +225,7 @@ var createPostRoute = (config2) => {
224
225
  const path6 = getRoutePath();
225
226
  return {
226
227
  POST: config2,
228
+ // Let TypeScript infer the proper types
227
229
  path: path6
228
230
  };
229
231
  };
@@ -232,6 +234,7 @@ var createPutRoute = (config2) => {
232
234
  const path6 = getRoutePath();
233
235
  return {
234
236
  PUT: config2,
237
+ // Let TypeScript infer the proper types
235
238
  path: path6
236
239
  };
237
240
  };
@@ -240,6 +243,7 @@ var createDeleteRoute = (config2) => {
240
243
  const path6 = getRoutePath();
241
244
  return {
242
245
  DELETE: config2,
246
+ // Let TypeScript infer the proper types
243
247
  path: path6
244
248
  };
245
249
  };
@@ -248,6 +252,7 @@ var createPatchRoute = (config2) => {
248
252
  const path6 = getRoutePath();
249
253
  return {
250
254
  PATCH: config2,
255
+ // Let TypeScript infer the proper types
251
256
  path: path6
252
257
  };
253
258
  };
@@ -256,6 +261,7 @@ var createHeadRoute = (config2) => {
256
261
  const path6 = getRoutePath();
257
262
  return {
258
263
  HEAD: config2,
264
+ // Let TypeScript infer the proper types
259
265
  path: path6
260
266
  };
261
267
  };
@@ -264,6 +270,7 @@ var createOptionsRoute = (config2) => {
264
270
  const path6 = getRoutePath();
265
271
  return {
266
272
  OPTIONS: config2,
273
+ // Let TypeScript infer the proper types
267
274
  path: path6
268
275
  };
269
276
  };
@@ -496,7 +503,7 @@ async function processCurrentStage(state) {
496
503
  case "content":
497
504
  return processContent(state);
498
505
  default: {
499
- const { InternalServerError: InternalServerError2 } = await import("./internal-server-error-CVRDTBLL.js");
506
+ const { InternalServerError: InternalServerError2 } = await import("./internal-server-error-PKVC3ZEU.js");
500
507
  throw new InternalServerError2(`Invalid parser stage`, {
501
508
  operation: state.stage
502
509
  });
@@ -535,13 +542,13 @@ async function processHeaders(state) {
535
542
  const buffer = state.buffer.subarray(headerEnd + 4);
536
543
  const disposition = parseContentDisposition(headers);
537
544
  if (!disposition) {
538
- const { ValidationError: ValidationError2 } = await import("./validation-error-CM6IKIJU.js");
545
+ const { ValidationError: ValidationError2 } = await import("./validation-error-WZFF75S7.js");
539
546
  throw new ValidationError2("Missing or invalid Content-Disposition header");
540
547
  }
541
548
  const mimetype = parseContentType(headers);
542
549
  const isFile = disposition.filename !== void 0;
543
550
  if (isFile && state.fileCount >= state.options.maxFiles) {
544
- const { PayloadTooLargeError } = await import("./payload-too-large-error-PAYLDBZT.js");
551
+ const { PayloadTooLargeError } = await import("./payload-too-large-error-WZMDORKR.js");
545
552
  throw new PayloadTooLargeError("Too many files in upload", {
546
553
  fileCount: state.fileCount + 1,
547
554
  maxFiles: state.options.maxFiles,
@@ -549,7 +556,7 @@ async function processHeaders(state) {
549
556
  });
550
557
  }
551
558
  if (isFile && state.options.allowedMimeTypes.length > 0 && !state.options.allowedMimeTypes.includes(mimetype)) {
552
- const { UnsupportedMediaTypeError } = await import("./unsupported-media-type-error-MQZD7YQJ.js");
559
+ const { UnsupportedMediaTypeError } = await import("./unsupported-media-type-error-VUXOJ72O.js");
553
560
  throw new UnsupportedMediaTypeError("File type not allowed", {
554
561
  receivedMimeType: mimetype,
555
562
  allowedMimeTypes: state.options.allowedMimeTypes,
@@ -606,7 +613,7 @@ async function processContentChunk(state, chunk) {
606
613
  const maxSize = state.currentFilename !== void 0 ? state.options.maxFileSize : state.options.maxFieldSize;
607
614
  if (newContentLength > maxSize) {
608
615
  const isFile = state.currentFilename !== void 0;
609
- const { PayloadTooLargeError } = await import("./payload-too-large-error-PAYLDBZT.js");
616
+ const { PayloadTooLargeError } = await import("./payload-too-large-error-WZMDORKR.js");
610
617
  const payloadErrorDetals = state.currentField ? {
611
618
  contentType: isFile ? "file" : "field",
612
619
  currentSize: newContentLength,
@@ -653,7 +660,7 @@ async function processFileChunk(state, chunk, newContentLength) {
653
660
  }
654
661
  return { ...state, currentContentLength: newContentLength };
655
662
  default: {
656
- const { ValidationError: ValidationError2 } = await import("./validation-error-CM6IKIJU.js");
663
+ const { ValidationError: ValidationError2 } = await import("./validation-error-WZFF75S7.js");
657
664
  throw new ValidationError2(`Invalid parsing strategy`);
658
665
  }
659
666
  }
@@ -696,7 +703,7 @@ async function initializeFileProcessing(state) {
696
703
  };
697
704
  }
698
705
  default: {
699
- const { ValidationError: ValidationError2 } = await import("./validation-error-CM6IKIJU.js");
706
+ const { ValidationError: ValidationError2 } = await import("./validation-error-WZFF75S7.js");
700
707
  throw new ValidationError2(`Invalid file processing strategy`);
701
708
  }
702
709
  }
@@ -735,7 +742,7 @@ async function finalizeFile(state) {
735
742
  stream = Readable.from(Buffer.alloc(0));
736
743
  break;
737
744
  default: {
738
- const { ValidationError: ValidationError2 } = await import("./validation-error-CM6IKIJU.js");
745
+ const { ValidationError: ValidationError2 } = await import("./validation-error-WZFF75S7.js");
739
746
  throw new ValidationError2(`Invalid file finalization strategy`);
740
747
  }
741
748
  }
@@ -784,11 +791,11 @@ function addToCollection(collection, key, value) {
784
791
  }
785
792
  async function finalize(state) {
786
793
  if (!state.hasFoundValidBoundary) {
787
- const { ValidationError: ValidationError2 } = await import("./validation-error-CM6IKIJU.js");
794
+ const { ValidationError: ValidationError2 } = await import("./validation-error-WZFF75S7.js");
788
795
  throw new ValidationError2("No valid multipart boundary found");
789
796
  }
790
797
  if (state.hasFoundValidBoundary && !state.hasProcessedAnyPart) {
791
- const { ValidationError: ValidationError2 } = await import("./validation-error-CM6IKIJU.js");
798
+ const { ValidationError: ValidationError2 } = await import("./validation-error-WZFF75S7.js");
792
799
  throw new ValidationError2("Empty multipart request");
793
800
  }
794
801
  const fields = {};
@@ -827,7 +834,7 @@ async function parseMultipartRequest(request, options = {}) {
827
834
  const contentType = request.headers["content-type"] || "";
828
835
  const boundary = extractBoundary(contentType);
829
836
  if (!boundary) {
830
- const { UnsupportedMediaTypeError } = await import("./unsupported-media-type-error-MQZD7YQJ.js");
837
+ const { UnsupportedMediaTypeError } = await import("./unsupported-media-type-error-VUXOJ72O.js");
831
838
  throw new UnsupportedMediaTypeError("Missing boundary in multipart content-type", {
832
839
  receivedContentType: contentType,
833
840
  expectedFormat: "multipart/form-data; boundary=..."