blaizejs 0.3.0 → 0.3.2
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/README.md +462 -646
- package/dist/{payload-too-large-error-PAYLDBZT.js → chunk-3VK325MM.js} +5 -3
- package/dist/{payload-too-large-error-PAYLDBZT.js.map → chunk-3VK325MM.js.map} +1 -1
- package/dist/{unsupported-media-type-error-MQZD7YQJ.js → chunk-7IM52S7P.js} +5 -3
- package/dist/{unsupported-media-type-error-MQZD7YQJ.js.map → chunk-7IM52S7P.js.map} +1 -1
- package/dist/{chunk-QQCQRHXJ.js → chunk-CQKM74J4.js} +4 -3
- package/dist/{chunk-QQCQRHXJ.js.map → chunk-CQKM74J4.js.map} +1 -1
- package/dist/{chunk-SRD3AB6T.js → chunk-HB6MRTGD.js} +4 -3
- package/dist/{chunk-SRD3AB6T.js.map → chunk-HB6MRTGD.js.map} +1 -1
- package/dist/{chunk-TCPQMZ23.js → chunk-IFP53BNM.js} +3 -2
- package/dist/{chunk-TCPQMZ23.js.map → chunk-IFP53BNM.js.map} +1 -1
- package/dist/index.cjs +53 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +155 -97
- package/dist/index.d.ts +155 -97
- package/dist/index.js +63 -19
- package/dist/index.js.map +1 -1
- package/dist/{internal-server-error-CVRDTBLL.js → internal-server-error-PVME2DGN.js} +5 -4
- package/dist/payload-too-large-error-QQG7MKGT.js +17 -0
- package/dist/unsupported-media-type-error-VVHRDTUH.js +17 -0
- package/dist/unsupported-media-type-error-VVHRDTUH.js.map +1 -0
- package/dist/{validation-error-CM6IKIJU.js → validation-error-TXMSFWZL.js} +5 -4
- package/dist/validation-error-TXMSFWZL.js.map +1 -0
- package/package.json +2 -2
- /package/dist/{internal-server-error-CVRDTBLL.js.map → internal-server-error-PVME2DGN.js.map} +0 -0
- /package/dist/{validation-error-CM6IKIJU.js.map → payload-too-large-error-QQG7MKGT.js.map} +0 -0
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
|
|
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,
|
|
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,
|
|
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
|
|
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,
|
|
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
|
|
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,
|
|
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
|
|
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,
|
|
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,
|
|
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
|
|
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,
|
|
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
|
|
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,
|
|
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,
|
|
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
|
|
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,
|
|
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,
|
|
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
|
|
1436
|
-
|
|
1437
|
-
} ?
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
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
|
|
1454
|
-
params?: Record<string,
|
|
1495
|
+
interface InternalRequestArgs {
|
|
1496
|
+
params?: Record<string, any>;
|
|
1455
1497
|
query?: Record<string, any>;
|
|
1456
|
-
body?:
|
|
1498
|
+
body?: any;
|
|
1457
1499
|
}
|
|
1458
1500
|
interface RequestOptions {
|
|
1459
1501
|
method: string;
|
|
@@ -1761,6 +1803,22 @@ declare class InternalServerError extends BlaizeError<InternalServerErrorDetails
|
|
|
1761
1803
|
constructor(title: string, details?: InternalServerErrorDetails | undefined, correlationId?: string | undefined);
|
|
1762
1804
|
}
|
|
1763
1805
|
|
|
1806
|
+
declare class PayloadTooLargeError extends BlaizeError<PayloadTooLargeErrorDetails> {
|
|
1807
|
+
constructor(title: string, details?: PayloadTooLargeErrorDetails | undefined, correlationId?: string);
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
declare class RequestTimeoutError extends BlaizeError {
|
|
1811
|
+
constructor(title: string, details?: unknown, correlationId?: string);
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
declare class UnsupportedMediaTypeError extends BlaizeError {
|
|
1815
|
+
constructor(title: string, details?: unknown, correlationId?: string);
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
declare class UnprocessableEntityError extends BlaizeError {
|
|
1819
|
+
constructor(title: string, details?: unknown, correlationId?: string);
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1764
1822
|
declare const VERSION = "0.1.0";
|
|
1765
1823
|
declare const ServerAPI: {
|
|
1766
1824
|
createServer: typeof create;
|
|
@@ -1808,4 +1866,4 @@ declare const Blaize: {
|
|
|
1808
1866
|
VERSION: string;
|
|
1809
1867
|
};
|
|
1810
1868
|
|
|
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
|
|
1869
|
+
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, PayloadTooLargeError, 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, RequestTimeoutError, 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, UnprocessableEntityError, UnsupportedMediaTypeError, 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,6 @@
|
|
|
1
|
+
|
|
1
2
|
/**
|
|
2
|
-
* blaizejs v0.3.
|
|
3
|
+
* blaizejs v0.3.2
|
|
3
4
|
* 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
5
|
*
|
|
5
6
|
* Copyright (c) 2025 BlaizeJS Contributors
|
|
@@ -8,10 +9,16 @@
|
|
|
8
9
|
|
|
9
10
|
import {
|
|
10
11
|
InternalServerError
|
|
11
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-CQKM74J4.js";
|
|
12
13
|
import {
|
|
13
14
|
ValidationError
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-HB6MRTGD.js";
|
|
16
|
+
import {
|
|
17
|
+
PayloadTooLargeError
|
|
18
|
+
} from "./chunk-3VK325MM.js";
|
|
19
|
+
import {
|
|
20
|
+
UnsupportedMediaTypeError
|
|
21
|
+
} from "./chunk-7IM52S7P.js";
|
|
15
22
|
import {
|
|
16
23
|
BlaizeError,
|
|
17
24
|
ErrorSeverity,
|
|
@@ -20,7 +27,7 @@ import {
|
|
|
20
27
|
generateCorrelationId,
|
|
21
28
|
getCurrentCorrelationId,
|
|
22
29
|
isBodyParseError
|
|
23
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-IFP53BNM.js";
|
|
24
31
|
|
|
25
32
|
// src/middleware/execute.ts
|
|
26
33
|
function execute(middleware, ctx, next) {
|
|
@@ -216,6 +223,7 @@ var createGetRoute = (config2) => {
|
|
|
216
223
|
const path6 = getRoutePath();
|
|
217
224
|
return {
|
|
218
225
|
GET: config2,
|
|
226
|
+
// Let TypeScript infer the proper types
|
|
219
227
|
path: path6
|
|
220
228
|
};
|
|
221
229
|
};
|
|
@@ -224,6 +232,7 @@ var createPostRoute = (config2) => {
|
|
|
224
232
|
const path6 = getRoutePath();
|
|
225
233
|
return {
|
|
226
234
|
POST: config2,
|
|
235
|
+
// Let TypeScript infer the proper types
|
|
227
236
|
path: path6
|
|
228
237
|
};
|
|
229
238
|
};
|
|
@@ -232,6 +241,7 @@ var createPutRoute = (config2) => {
|
|
|
232
241
|
const path6 = getRoutePath();
|
|
233
242
|
return {
|
|
234
243
|
PUT: config2,
|
|
244
|
+
// Let TypeScript infer the proper types
|
|
235
245
|
path: path6
|
|
236
246
|
};
|
|
237
247
|
};
|
|
@@ -240,6 +250,7 @@ var createDeleteRoute = (config2) => {
|
|
|
240
250
|
const path6 = getRoutePath();
|
|
241
251
|
return {
|
|
242
252
|
DELETE: config2,
|
|
253
|
+
// Let TypeScript infer the proper types
|
|
243
254
|
path: path6
|
|
244
255
|
};
|
|
245
256
|
};
|
|
@@ -248,6 +259,7 @@ var createPatchRoute = (config2) => {
|
|
|
248
259
|
const path6 = getRoutePath();
|
|
249
260
|
return {
|
|
250
261
|
PATCH: config2,
|
|
262
|
+
// Let TypeScript infer the proper types
|
|
251
263
|
path: path6
|
|
252
264
|
};
|
|
253
265
|
};
|
|
@@ -256,6 +268,7 @@ var createHeadRoute = (config2) => {
|
|
|
256
268
|
const path6 = getRoutePath();
|
|
257
269
|
return {
|
|
258
270
|
HEAD: config2,
|
|
271
|
+
// Let TypeScript infer the proper types
|
|
259
272
|
path: path6
|
|
260
273
|
};
|
|
261
274
|
};
|
|
@@ -264,6 +277,7 @@ var createOptionsRoute = (config2) => {
|
|
|
264
277
|
const path6 = getRoutePath();
|
|
265
278
|
return {
|
|
266
279
|
OPTIONS: config2,
|
|
280
|
+
// Let TypeScript infer the proper types
|
|
267
281
|
path: path6
|
|
268
282
|
};
|
|
269
283
|
};
|
|
@@ -496,7 +510,7 @@ async function processCurrentStage(state) {
|
|
|
496
510
|
case "content":
|
|
497
511
|
return processContent(state);
|
|
498
512
|
default: {
|
|
499
|
-
const { InternalServerError: InternalServerError2 } = await import("./internal-server-error-
|
|
513
|
+
const { InternalServerError: InternalServerError2 } = await import("./internal-server-error-PVME2DGN.js");
|
|
500
514
|
throw new InternalServerError2(`Invalid parser stage`, {
|
|
501
515
|
operation: state.stage
|
|
502
516
|
});
|
|
@@ -535,22 +549,22 @@ async function processHeaders(state) {
|
|
|
535
549
|
const buffer = state.buffer.subarray(headerEnd + 4);
|
|
536
550
|
const disposition = parseContentDisposition(headers);
|
|
537
551
|
if (!disposition) {
|
|
538
|
-
const { ValidationError: ValidationError2 } = await import("./validation-error-
|
|
552
|
+
const { ValidationError: ValidationError2 } = await import("./validation-error-TXMSFWZL.js");
|
|
539
553
|
throw new ValidationError2("Missing or invalid Content-Disposition header");
|
|
540
554
|
}
|
|
541
555
|
const mimetype = parseContentType(headers);
|
|
542
556
|
const isFile = disposition.filename !== void 0;
|
|
543
557
|
if (isFile && state.fileCount >= state.options.maxFiles) {
|
|
544
|
-
const { PayloadTooLargeError } = await import("./payload-too-large-error-
|
|
545
|
-
throw new
|
|
558
|
+
const { PayloadTooLargeError: PayloadTooLargeError2 } = await import("./payload-too-large-error-QQG7MKGT.js");
|
|
559
|
+
throw new PayloadTooLargeError2("Too many files in upload", {
|
|
546
560
|
fileCount: state.fileCount + 1,
|
|
547
561
|
maxFiles: state.options.maxFiles,
|
|
548
562
|
filename: disposition.filename
|
|
549
563
|
});
|
|
550
564
|
}
|
|
551
565
|
if (isFile && state.options.allowedMimeTypes.length > 0 && !state.options.allowedMimeTypes.includes(mimetype)) {
|
|
552
|
-
const { UnsupportedMediaTypeError } = await import("./unsupported-media-type-error-
|
|
553
|
-
throw new
|
|
566
|
+
const { UnsupportedMediaTypeError: UnsupportedMediaTypeError2 } = await import("./unsupported-media-type-error-VVHRDTUH.js");
|
|
567
|
+
throw new UnsupportedMediaTypeError2("File type not allowed", {
|
|
554
568
|
receivedMimeType: mimetype,
|
|
555
569
|
allowedMimeTypes: state.options.allowedMimeTypes,
|
|
556
570
|
filename: disposition.filename
|
|
@@ -606,7 +620,7 @@ async function processContentChunk(state, chunk) {
|
|
|
606
620
|
const maxSize = state.currentFilename !== void 0 ? state.options.maxFileSize : state.options.maxFieldSize;
|
|
607
621
|
if (newContentLength > maxSize) {
|
|
608
622
|
const isFile = state.currentFilename !== void 0;
|
|
609
|
-
const { PayloadTooLargeError } = await import("./payload-too-large-error-
|
|
623
|
+
const { PayloadTooLargeError: PayloadTooLargeError2 } = await import("./payload-too-large-error-QQG7MKGT.js");
|
|
610
624
|
const payloadErrorDetals = state.currentField ? {
|
|
611
625
|
contentType: isFile ? "file" : "field",
|
|
612
626
|
currentSize: newContentLength,
|
|
@@ -619,7 +633,7 @@ async function processContentChunk(state, chunk) {
|
|
|
619
633
|
maxSize,
|
|
620
634
|
filename: state.currentFilename
|
|
621
635
|
};
|
|
622
|
-
throw new
|
|
636
|
+
throw new PayloadTooLargeError2(
|
|
623
637
|
`${isFile ? "File" : "Field"} size exceeds limit`,
|
|
624
638
|
payloadErrorDetals
|
|
625
639
|
);
|
|
@@ -653,7 +667,7 @@ async function processFileChunk(state, chunk, newContentLength) {
|
|
|
653
667
|
}
|
|
654
668
|
return { ...state, currentContentLength: newContentLength };
|
|
655
669
|
default: {
|
|
656
|
-
const { ValidationError: ValidationError2 } = await import("./validation-error-
|
|
670
|
+
const { ValidationError: ValidationError2 } = await import("./validation-error-TXMSFWZL.js");
|
|
657
671
|
throw new ValidationError2(`Invalid parsing strategy`);
|
|
658
672
|
}
|
|
659
673
|
}
|
|
@@ -696,7 +710,7 @@ async function initializeFileProcessing(state) {
|
|
|
696
710
|
};
|
|
697
711
|
}
|
|
698
712
|
default: {
|
|
699
|
-
const { ValidationError: ValidationError2 } = await import("./validation-error-
|
|
713
|
+
const { ValidationError: ValidationError2 } = await import("./validation-error-TXMSFWZL.js");
|
|
700
714
|
throw new ValidationError2(`Invalid file processing strategy`);
|
|
701
715
|
}
|
|
702
716
|
}
|
|
@@ -735,7 +749,7 @@ async function finalizeFile(state) {
|
|
|
735
749
|
stream = Readable.from(Buffer.alloc(0));
|
|
736
750
|
break;
|
|
737
751
|
default: {
|
|
738
|
-
const { ValidationError: ValidationError2 } = await import("./validation-error-
|
|
752
|
+
const { ValidationError: ValidationError2 } = await import("./validation-error-TXMSFWZL.js");
|
|
739
753
|
throw new ValidationError2(`Invalid file finalization strategy`);
|
|
740
754
|
}
|
|
741
755
|
}
|
|
@@ -784,11 +798,11 @@ function addToCollection(collection, key, value) {
|
|
|
784
798
|
}
|
|
785
799
|
async function finalize(state) {
|
|
786
800
|
if (!state.hasFoundValidBoundary) {
|
|
787
|
-
const { ValidationError: ValidationError2 } = await import("./validation-error-
|
|
801
|
+
const { ValidationError: ValidationError2 } = await import("./validation-error-TXMSFWZL.js");
|
|
788
802
|
throw new ValidationError2("No valid multipart boundary found");
|
|
789
803
|
}
|
|
790
804
|
if (state.hasFoundValidBoundary && !state.hasProcessedAnyPart) {
|
|
791
|
-
const { ValidationError: ValidationError2 } = await import("./validation-error-
|
|
805
|
+
const { ValidationError: ValidationError2 } = await import("./validation-error-TXMSFWZL.js");
|
|
792
806
|
throw new ValidationError2("Empty multipart request");
|
|
793
807
|
}
|
|
794
808
|
const fields = {};
|
|
@@ -827,8 +841,8 @@ async function parseMultipartRequest(request, options = {}) {
|
|
|
827
841
|
const contentType = request.headers["content-type"] || "";
|
|
828
842
|
const boundary = extractBoundary(contentType);
|
|
829
843
|
if (!boundary) {
|
|
830
|
-
const { UnsupportedMediaTypeError } = await import("./unsupported-media-type-error-
|
|
831
|
-
throw new
|
|
844
|
+
const { UnsupportedMediaTypeError: UnsupportedMediaTypeError2 } = await import("./unsupported-media-type-error-VVHRDTUH.js");
|
|
845
|
+
throw new UnsupportedMediaTypeError2("Missing boundary in multipart content-type", {
|
|
832
846
|
receivedContentType: contentType,
|
|
833
847
|
expectedFormat: "multipart/form-data; boundary=..."
|
|
834
848
|
});
|
|
@@ -3066,6 +3080,32 @@ var RateLimitError = class extends BlaizeError {
|
|
|
3066
3080
|
}
|
|
3067
3081
|
};
|
|
3068
3082
|
|
|
3083
|
+
// src/errors/request-timeout-error.ts
|
|
3084
|
+
var RequestTimeoutError = class extends BlaizeError {
|
|
3085
|
+
constructor(title, details, correlationId) {
|
|
3086
|
+
super(
|
|
3087
|
+
"UPLOAD_TIMEOUT" /* UPLOAD_TIMEOUT */,
|
|
3088
|
+
title,
|
|
3089
|
+
408,
|
|
3090
|
+
correlationId ?? getCurrentCorrelationId(),
|
|
3091
|
+
details
|
|
3092
|
+
);
|
|
3093
|
+
}
|
|
3094
|
+
};
|
|
3095
|
+
|
|
3096
|
+
// src/errors/unprocessable-entity-error.ts
|
|
3097
|
+
var UnprocessableEntityError = class extends BlaizeError {
|
|
3098
|
+
constructor(title, details, correlationId) {
|
|
3099
|
+
super(
|
|
3100
|
+
"UNPROCESSABLE_ENTITY" /* UNPROCESSABLE_ENTITY */,
|
|
3101
|
+
title,
|
|
3102
|
+
422,
|
|
3103
|
+
correlationId ?? getCurrentCorrelationId(),
|
|
3104
|
+
details
|
|
3105
|
+
);
|
|
3106
|
+
}
|
|
3107
|
+
};
|
|
3108
|
+
|
|
3069
3109
|
// src/index.ts
|
|
3070
3110
|
var VERSION = "0.1.0";
|
|
3071
3111
|
var ServerAPI = { createServer: create3 };
|
|
@@ -3104,11 +3144,15 @@ export {
|
|
|
3104
3144
|
InternalServerError,
|
|
3105
3145
|
MiddlewareAPI,
|
|
3106
3146
|
NotFoundError,
|
|
3147
|
+
PayloadTooLargeError,
|
|
3107
3148
|
PluginsAPI,
|
|
3108
3149
|
RateLimitError,
|
|
3150
|
+
RequestTimeoutError,
|
|
3109
3151
|
RouterAPI,
|
|
3110
3152
|
ServerAPI,
|
|
3111
3153
|
UnauthorizedError,
|
|
3154
|
+
UnprocessableEntityError,
|
|
3155
|
+
UnsupportedMediaTypeError,
|
|
3112
3156
|
VERSION,
|
|
3113
3157
|
ValidationError,
|
|
3114
3158
|
compose,
|