@minisylar/express-typed-router 1.4.4 → 1.5.0
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/zod-router.d.cts +123 -49
- package/dist/zod-router.d.ts +123 -49
- package/package.json +2 -2
package/dist/zod-router.d.cts
CHANGED
|
@@ -94,7 +94,7 @@ type ZodRequest<Path extends string = string, BodySchema extends AnyZodType | un
|
|
|
94
94
|
body: BodySchema extends AnyZodType ? InferOutput<BodySchema> : unknown;
|
|
95
95
|
query: QuerySchema extends AnyZodType ? InferOutput<QuerySchema> : unknown;
|
|
96
96
|
} & MiddlewareProps;
|
|
97
|
-
type ZodRouteHandler<Path extends string = string, BodySchema extends AnyZodType | unknown = unknown, QuerySchema extends AnyZodType | unknown = unknown, MiddlewareProps extends Record<string, any> = {}, ResponseLocals extends Record<string, any> = {}> = (req: ZodRequest<Path, BodySchema, QuerySchema, MiddlewareProps>, res: Response<any, ResponseLocals>, next?: NextFunction) => void | Promise<void> | Response | Promise<Response>;
|
|
97
|
+
type ZodRouteHandler<Path extends string = string, BodySchema extends AnyZodType | unknown = unknown, QuerySchema extends AnyZodType | unknown = unknown, MiddlewareProps extends Record<string, any> = {}, ResponseLocals extends Record<string, any> = {}> = (req: ZodRequest<Path, BodySchema, QuerySchema, MiddlewareProps>, res: Response<any, ResponseLocals>, next?: NextFunction) => void | undefined | Promise<void | undefined> | Response | Promise<Response> | Promise<Response | undefined>;
|
|
98
98
|
/**
|
|
99
99
|
* Options for defining a typed route, including schemas and middleware.
|
|
100
100
|
*
|
|
@@ -170,84 +170,158 @@ declare class TypedRouter<RouterMiddlewareProps extends Record<string, any> = {}
|
|
|
170
170
|
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
171
171
|
post<Path extends string, BodySchema extends AnyZodType | unknown, QuerySchema extends AnyZodType | unknown>(path: Path, options: RouteOptions<BodySchema, QuerySchema>, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
172
172
|
post<Path extends string>(path: Path, handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
173
|
-
put<Path extends string, BodySchema extends AnyZodType, QuerySchema extends AnyZodType | unknown,
|
|
173
|
+
put<Path extends string, BodySchema extends AnyZodType, QuerySchema extends AnyZodType | unknown, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
174
174
|
bodySchema: BodySchema;
|
|
175
175
|
querySchema?: QuerySchema;
|
|
176
|
-
middleware:
|
|
177
|
-
}, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<
|
|
178
|
-
|
|
176
|
+
middleware: [...M];
|
|
177
|
+
}, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
178
|
+
// Make it readonly for type inference
|
|
179
|
+
// Make it readonly for type inference
|
|
180
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
181
|
+
put<Path extends string, BodySchema extends AnyZodType, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
179
182
|
bodySchema: BodySchema;
|
|
180
|
-
middleware:
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
middleware: [...M];
|
|
184
|
+
},
|
|
185
|
+
// Using tuple spread pattern
|
|
186
|
+
handler: ZodRouteHandler<Path, BodySchema, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
187
|
+
// Make it readonly for type inference
|
|
188
|
+
// Make it readonly for type inference
|
|
189
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
190
|
+
put<Path extends string, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
191
|
+
middleware: [...M];
|
|
192
|
+
},
|
|
193
|
+
// Using tuple spread pattern
|
|
194
|
+
handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
195
|
+
// Make it readonly for type inference
|
|
196
|
+
// Make it readonly for type inference
|
|
197
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
185
198
|
put<Path extends string, BodySchema extends AnyZodType | unknown, QuerySchema extends AnyZodType | unknown>(path: Path, options: RouteOptions<BodySchema, QuerySchema>, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
186
199
|
put<Path extends string>(path: Path, handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
187
|
-
patch<Path extends string, BodySchema extends AnyZodType, QuerySchema extends AnyZodType | unknown,
|
|
200
|
+
patch<Path extends string, BodySchema extends AnyZodType, QuerySchema extends AnyZodType | unknown, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
188
201
|
bodySchema: BodySchema;
|
|
189
202
|
querySchema?: QuerySchema;
|
|
190
|
-
middleware:
|
|
191
|
-
}, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<
|
|
192
|
-
|
|
203
|
+
middleware: [...M];
|
|
204
|
+
}, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
205
|
+
// Make it readonly for type inference
|
|
206
|
+
// Make it readonly for type inference
|
|
207
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
208
|
+
patch<Path extends string, BodySchema extends AnyZodType, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
193
209
|
bodySchema: BodySchema;
|
|
194
|
-
middleware:
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
210
|
+
middleware: [...M];
|
|
211
|
+
},
|
|
212
|
+
// Using tuple spread pattern
|
|
213
|
+
handler: ZodRouteHandler<Path, BodySchema, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
214
|
+
// Make it readonly for type inference
|
|
215
|
+
// Make it readonly for type inference
|
|
216
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
217
|
+
patch<Path extends string, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
218
|
+
middleware: [...M];
|
|
219
|
+
},
|
|
220
|
+
// Using tuple spread pattern
|
|
221
|
+
handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
222
|
+
// Make it readonly for type inference
|
|
223
|
+
// Make it readonly for type inference
|
|
224
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
199
225
|
patch<Path extends string, BodySchema extends AnyZodType | unknown, QuerySchema extends AnyZodType | unknown>(path: Path, options: RouteOptions<BodySchema, QuerySchema>, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
200
226
|
patch<Path extends string>(path: Path, handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
201
|
-
delete<Path extends string, QuerySchema extends AnyZodType | unknown,
|
|
227
|
+
delete<Path extends string, QuerySchema extends AnyZodType | unknown, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
202
228
|
querySchema: QuerySchema;
|
|
203
|
-
middleware:
|
|
204
|
-
},
|
|
229
|
+
middleware: [...M];
|
|
230
|
+
},
|
|
231
|
+
// Using tuple spread pattern
|
|
232
|
+
handler: ZodRouteHandler<Path, unknown, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
233
|
+
// Make it readonly for type inference
|
|
234
|
+
// Make it readonly for type inference
|
|
235
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
205
236
|
delete<Path extends string, QuerySchema extends AnyZodType | unknown>(path: Path, options: {
|
|
206
237
|
querySchema: QuerySchema;
|
|
207
238
|
}, handler: ZodRouteHandler<Path, unknown, QuerySchema, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
208
|
-
delete<Path extends string,
|
|
209
|
-
middleware:
|
|
210
|
-
},
|
|
239
|
+
delete<Path extends string, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
240
|
+
middleware: [...M];
|
|
241
|
+
},
|
|
242
|
+
// Using tuple spread pattern
|
|
243
|
+
handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
244
|
+
// Make it readonly for type inference
|
|
245
|
+
// Make it readonly for type inference
|
|
246
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
211
247
|
delete<Path extends string>(path: Path, handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
212
|
-
options<Path extends string, QuerySchema extends AnyZodType | unknown,
|
|
248
|
+
options<Path extends string, QuerySchema extends AnyZodType | unknown, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
213
249
|
querySchema: QuerySchema;
|
|
214
|
-
middleware:
|
|
215
|
-
},
|
|
250
|
+
middleware: [...M];
|
|
251
|
+
},
|
|
252
|
+
// Using tuple spread pattern
|
|
253
|
+
handler: ZodRouteHandler<Path, unknown, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
254
|
+
// Make it readonly for type inference
|
|
255
|
+
// Make it readonly for type inference
|
|
256
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
216
257
|
options<Path extends string, QuerySchema extends AnyZodType | unknown>(path: Path, options: {
|
|
217
258
|
querySchema: QuerySchema;
|
|
218
259
|
}, handler: ZodRouteHandler<Path, unknown, QuerySchema, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
219
|
-
options<Path extends string,
|
|
220
|
-
middleware:
|
|
221
|
-
},
|
|
260
|
+
options<Path extends string, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
261
|
+
middleware: [...M];
|
|
262
|
+
},
|
|
263
|
+
// Using tuple spread pattern
|
|
264
|
+
handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
265
|
+
// Make it readonly for type inference
|
|
266
|
+
// Make it readonly for type inference
|
|
267
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
222
268
|
options<Path extends string>(path: Path, handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
223
|
-
head<Path extends string, QuerySchema extends AnyZodType | unknown,
|
|
269
|
+
head<Path extends string, QuerySchema extends AnyZodType | unknown, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
224
270
|
querySchema: QuerySchema;
|
|
225
|
-
middleware:
|
|
226
|
-
},
|
|
271
|
+
middleware: [...M];
|
|
272
|
+
},
|
|
273
|
+
// Using tuple spread pattern
|
|
274
|
+
handler: ZodRouteHandler<Path, unknown, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
275
|
+
// Make it readonly for type inference
|
|
276
|
+
// Make it readonly for type inference
|
|
277
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
227
278
|
head<Path extends string, QuerySchema extends AnyZodType | unknown>(path: Path, options: {
|
|
228
279
|
querySchema: QuerySchema;
|
|
229
280
|
}, handler: ZodRouteHandler<Path, unknown, QuerySchema, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
230
|
-
head<Path extends string,
|
|
231
|
-
middleware:
|
|
232
|
-
},
|
|
281
|
+
head<Path extends string, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
282
|
+
middleware: [...M];
|
|
283
|
+
},
|
|
284
|
+
// Using tuple spread pattern
|
|
285
|
+
handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
286
|
+
// Make it readonly for type inference
|
|
287
|
+
// Make it readonly for type inference
|
|
288
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
233
289
|
head<Path extends string>(path: Path, handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
234
|
-
all<Path extends string, BodySchema extends AnyZodType, QuerySchema extends AnyZodType | unknown,
|
|
290
|
+
all<Path extends string, BodySchema extends AnyZodType, QuerySchema extends AnyZodType | unknown, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
235
291
|
bodySchema: BodySchema;
|
|
236
292
|
querySchema?: QuerySchema;
|
|
237
|
-
middleware:
|
|
238
|
-
}, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<
|
|
239
|
-
|
|
293
|
+
middleware: [...M];
|
|
294
|
+
}, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
295
|
+
// Make it readonly for type inference
|
|
296
|
+
// Make it readonly for type inference
|
|
297
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
298
|
+
all<Path extends string, BodySchema extends AnyZodType, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
240
299
|
bodySchema: BodySchema;
|
|
241
|
-
middleware:
|
|
242
|
-
},
|
|
243
|
-
|
|
300
|
+
middleware: [...M];
|
|
301
|
+
},
|
|
302
|
+
// Using tuple spread pattern
|
|
303
|
+
handler: ZodRouteHandler<Path, BodySchema, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
304
|
+
// Make it readonly for type inference
|
|
305
|
+
// Make it readonly for type inference
|
|
306
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
307
|
+
all<Path extends string, QuerySchema extends AnyZodType | unknown, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
244
308
|
querySchema: QuerySchema;
|
|
245
|
-
middleware:
|
|
246
|
-
},
|
|
309
|
+
middleware: [...M];
|
|
310
|
+
},
|
|
311
|
+
// Using tuple spread pattern
|
|
312
|
+
handler: ZodRouteHandler<Path, unknown, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
313
|
+
// Make it readonly for type inference
|
|
314
|
+
// Make it readonly for type inference
|
|
315
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
247
316
|
all<Path extends string, BodySchema extends AnyZodType | unknown, QuerySchema extends AnyZodType | unknown>(path: Path, options: RouteOptions<BodySchema, QuerySchema>, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
248
|
-
all<Path extends string,
|
|
249
|
-
middleware:
|
|
250
|
-
},
|
|
317
|
+
all<Path extends string, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
318
|
+
middleware: [...M];
|
|
319
|
+
},
|
|
320
|
+
// Using tuple spread pattern
|
|
321
|
+
handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
322
|
+
// Make it readonly for type inference
|
|
323
|
+
// Make it readonly for type inference
|
|
324
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
251
325
|
all<Path extends string>(path: Path, handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
252
326
|
private registerRoute;
|
|
253
327
|
private createBodyValidationMiddleware;
|
package/dist/zod-router.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ type ZodRequest<Path extends string = string, BodySchema extends AnyZodType | un
|
|
|
94
94
|
body: BodySchema extends AnyZodType ? InferOutput<BodySchema> : unknown;
|
|
95
95
|
query: QuerySchema extends AnyZodType ? InferOutput<QuerySchema> : unknown;
|
|
96
96
|
} & MiddlewareProps;
|
|
97
|
-
type ZodRouteHandler<Path extends string = string, BodySchema extends AnyZodType | unknown = unknown, QuerySchema extends AnyZodType | unknown = unknown, MiddlewareProps extends Record<string, any> = {}, ResponseLocals extends Record<string, any> = {}> = (req: ZodRequest<Path, BodySchema, QuerySchema, MiddlewareProps>, res: Response<any, ResponseLocals>, next?: NextFunction) => void | Promise<void> | Response | Promise<Response>;
|
|
97
|
+
type ZodRouteHandler<Path extends string = string, BodySchema extends AnyZodType | unknown = unknown, QuerySchema extends AnyZodType | unknown = unknown, MiddlewareProps extends Record<string, any> = {}, ResponseLocals extends Record<string, any> = {}> = (req: ZodRequest<Path, BodySchema, QuerySchema, MiddlewareProps>, res: Response<any, ResponseLocals>, next?: NextFunction) => void | undefined | Promise<void | undefined> | Response | Promise<Response> | Promise<Response | undefined>;
|
|
98
98
|
/**
|
|
99
99
|
* Options for defining a typed route, including schemas and middleware.
|
|
100
100
|
*
|
|
@@ -170,84 +170,158 @@ declare class TypedRouter<RouterMiddlewareProps extends Record<string, any> = {}
|
|
|
170
170
|
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
171
171
|
post<Path extends string, BodySchema extends AnyZodType | unknown, QuerySchema extends AnyZodType | unknown>(path: Path, options: RouteOptions<BodySchema, QuerySchema>, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
172
172
|
post<Path extends string>(path: Path, handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
173
|
-
put<Path extends string, BodySchema extends AnyZodType, QuerySchema extends AnyZodType | unknown,
|
|
173
|
+
put<Path extends string, BodySchema extends AnyZodType, QuerySchema extends AnyZodType | unknown, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
174
174
|
bodySchema: BodySchema;
|
|
175
175
|
querySchema?: QuerySchema;
|
|
176
|
-
middleware:
|
|
177
|
-
}, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<
|
|
178
|
-
|
|
176
|
+
middleware: [...M];
|
|
177
|
+
}, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
178
|
+
// Make it readonly for type inference
|
|
179
|
+
// Make it readonly for type inference
|
|
180
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
181
|
+
put<Path extends string, BodySchema extends AnyZodType, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
179
182
|
bodySchema: BodySchema;
|
|
180
|
-
middleware:
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
middleware: [...M];
|
|
184
|
+
},
|
|
185
|
+
// Using tuple spread pattern
|
|
186
|
+
handler: ZodRouteHandler<Path, BodySchema, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
187
|
+
// Make it readonly for type inference
|
|
188
|
+
// Make it readonly for type inference
|
|
189
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
190
|
+
put<Path extends string, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
191
|
+
middleware: [...M];
|
|
192
|
+
},
|
|
193
|
+
// Using tuple spread pattern
|
|
194
|
+
handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
195
|
+
// Make it readonly for type inference
|
|
196
|
+
// Make it readonly for type inference
|
|
197
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
185
198
|
put<Path extends string, BodySchema extends AnyZodType | unknown, QuerySchema extends AnyZodType | unknown>(path: Path, options: RouteOptions<BodySchema, QuerySchema>, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
186
199
|
put<Path extends string>(path: Path, handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
187
|
-
patch<Path extends string, BodySchema extends AnyZodType, QuerySchema extends AnyZodType | unknown,
|
|
200
|
+
patch<Path extends string, BodySchema extends AnyZodType, QuerySchema extends AnyZodType | unknown, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
188
201
|
bodySchema: BodySchema;
|
|
189
202
|
querySchema?: QuerySchema;
|
|
190
|
-
middleware:
|
|
191
|
-
}, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<
|
|
192
|
-
|
|
203
|
+
middleware: [...M];
|
|
204
|
+
}, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
205
|
+
// Make it readonly for type inference
|
|
206
|
+
// Make it readonly for type inference
|
|
207
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
208
|
+
patch<Path extends string, BodySchema extends AnyZodType, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
193
209
|
bodySchema: BodySchema;
|
|
194
|
-
middleware:
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
210
|
+
middleware: [...M];
|
|
211
|
+
},
|
|
212
|
+
// Using tuple spread pattern
|
|
213
|
+
handler: ZodRouteHandler<Path, BodySchema, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
214
|
+
// Make it readonly for type inference
|
|
215
|
+
// Make it readonly for type inference
|
|
216
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
217
|
+
patch<Path extends string, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
218
|
+
middleware: [...M];
|
|
219
|
+
},
|
|
220
|
+
// Using tuple spread pattern
|
|
221
|
+
handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
222
|
+
// Make it readonly for type inference
|
|
223
|
+
// Make it readonly for type inference
|
|
224
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
199
225
|
patch<Path extends string, BodySchema extends AnyZodType | unknown, QuerySchema extends AnyZodType | unknown>(path: Path, options: RouteOptions<BodySchema, QuerySchema>, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
200
226
|
patch<Path extends string>(path: Path, handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
201
|
-
delete<Path extends string, QuerySchema extends AnyZodType | unknown,
|
|
227
|
+
delete<Path extends string, QuerySchema extends AnyZodType | unknown, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
202
228
|
querySchema: QuerySchema;
|
|
203
|
-
middleware:
|
|
204
|
-
},
|
|
229
|
+
middleware: [...M];
|
|
230
|
+
},
|
|
231
|
+
// Using tuple spread pattern
|
|
232
|
+
handler: ZodRouteHandler<Path, unknown, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
233
|
+
// Make it readonly for type inference
|
|
234
|
+
// Make it readonly for type inference
|
|
235
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
205
236
|
delete<Path extends string, QuerySchema extends AnyZodType | unknown>(path: Path, options: {
|
|
206
237
|
querySchema: QuerySchema;
|
|
207
238
|
}, handler: ZodRouteHandler<Path, unknown, QuerySchema, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
208
|
-
delete<Path extends string,
|
|
209
|
-
middleware:
|
|
210
|
-
},
|
|
239
|
+
delete<Path extends string, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
240
|
+
middleware: [...M];
|
|
241
|
+
},
|
|
242
|
+
// Using tuple spread pattern
|
|
243
|
+
handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
244
|
+
// Make it readonly for type inference
|
|
245
|
+
// Make it readonly for type inference
|
|
246
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
211
247
|
delete<Path extends string>(path: Path, handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
212
|
-
options<Path extends string, QuerySchema extends AnyZodType | unknown,
|
|
248
|
+
options<Path extends string, QuerySchema extends AnyZodType | unknown, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
213
249
|
querySchema: QuerySchema;
|
|
214
|
-
middleware:
|
|
215
|
-
},
|
|
250
|
+
middleware: [...M];
|
|
251
|
+
},
|
|
252
|
+
// Using tuple spread pattern
|
|
253
|
+
handler: ZodRouteHandler<Path, unknown, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
254
|
+
// Make it readonly for type inference
|
|
255
|
+
// Make it readonly for type inference
|
|
256
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
216
257
|
options<Path extends string, QuerySchema extends AnyZodType | unknown>(path: Path, options: {
|
|
217
258
|
querySchema: QuerySchema;
|
|
218
259
|
}, handler: ZodRouteHandler<Path, unknown, QuerySchema, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
219
|
-
options<Path extends string,
|
|
220
|
-
middleware:
|
|
221
|
-
},
|
|
260
|
+
options<Path extends string, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
261
|
+
middleware: [...M];
|
|
262
|
+
},
|
|
263
|
+
// Using tuple spread pattern
|
|
264
|
+
handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
265
|
+
// Make it readonly for type inference
|
|
266
|
+
// Make it readonly for type inference
|
|
267
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
222
268
|
options<Path extends string>(path: Path, handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
223
|
-
head<Path extends string, QuerySchema extends AnyZodType | unknown,
|
|
269
|
+
head<Path extends string, QuerySchema extends AnyZodType | unknown, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
224
270
|
querySchema: QuerySchema;
|
|
225
|
-
middleware:
|
|
226
|
-
},
|
|
271
|
+
middleware: [...M];
|
|
272
|
+
},
|
|
273
|
+
// Using tuple spread pattern
|
|
274
|
+
handler: ZodRouteHandler<Path, unknown, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
275
|
+
// Make it readonly for type inference
|
|
276
|
+
// Make it readonly for type inference
|
|
277
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
227
278
|
head<Path extends string, QuerySchema extends AnyZodType | unknown>(path: Path, options: {
|
|
228
279
|
querySchema: QuerySchema;
|
|
229
280
|
}, handler: ZodRouteHandler<Path, unknown, QuerySchema, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
230
|
-
head<Path extends string,
|
|
231
|
-
middleware:
|
|
232
|
-
},
|
|
281
|
+
head<Path extends string, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
282
|
+
middleware: [...M];
|
|
283
|
+
},
|
|
284
|
+
// Using tuple spread pattern
|
|
285
|
+
handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
286
|
+
// Make it readonly for type inference
|
|
287
|
+
// Make it readonly for type inference
|
|
288
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
233
289
|
head<Path extends string>(path: Path, handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
234
|
-
all<Path extends string, BodySchema extends AnyZodType, QuerySchema extends AnyZodType | unknown,
|
|
290
|
+
all<Path extends string, BodySchema extends AnyZodType, QuerySchema extends AnyZodType | unknown, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
235
291
|
bodySchema: BodySchema;
|
|
236
292
|
querySchema?: QuerySchema;
|
|
237
|
-
middleware:
|
|
238
|
-
}, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<
|
|
239
|
-
|
|
293
|
+
middleware: [...M];
|
|
294
|
+
}, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
295
|
+
// Make it readonly for type inference
|
|
296
|
+
// Make it readonly for type inference
|
|
297
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
298
|
+
all<Path extends string, BodySchema extends AnyZodType, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
240
299
|
bodySchema: BodySchema;
|
|
241
|
-
middleware:
|
|
242
|
-
},
|
|
243
|
-
|
|
300
|
+
middleware: [...M];
|
|
301
|
+
},
|
|
302
|
+
// Using tuple spread pattern
|
|
303
|
+
handler: ZodRouteHandler<Path, BodySchema, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
304
|
+
// Make it readonly for type inference
|
|
305
|
+
// Make it readonly for type inference
|
|
306
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
307
|
+
all<Path extends string, QuerySchema extends AnyZodType | unknown, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
244
308
|
querySchema: QuerySchema;
|
|
245
|
-
middleware:
|
|
246
|
-
},
|
|
309
|
+
middleware: [...M];
|
|
310
|
+
},
|
|
311
|
+
// Using tuple spread pattern
|
|
312
|
+
handler: ZodRouteHandler<Path, unknown, QuerySchema, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
313
|
+
// Make it readonly for type inference
|
|
314
|
+
// Make it readonly for type inference
|
|
315
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
247
316
|
all<Path extends string, BodySchema extends AnyZodType | unknown, QuerySchema extends AnyZodType | unknown>(path: Path, options: RouteOptions<BodySchema, QuerySchema>, handler: ZodRouteHandler<Path, BodySchema, QuerySchema, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
248
|
-
all<Path extends string,
|
|
249
|
-
middleware:
|
|
250
|
-
},
|
|
317
|
+
all<Path extends string, M extends TypedMiddleware<any, any>[]>(path: Path, options: {
|
|
318
|
+
middleware: [...M];
|
|
319
|
+
},
|
|
320
|
+
// Using tuple spread pattern
|
|
321
|
+
handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps & InferMiddlewareProps<readonly [...M]>,
|
|
322
|
+
// Make it readonly for type inference
|
|
323
|
+
// Make it readonly for type inference
|
|
324
|
+
RouterLocals & InferMiddlewareLocals<readonly [...M]>>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
251
325
|
all<Path extends string>(path: Path, handler: ZodRouteHandler<Path, unknown, unknown, RouterMiddlewareProps, RouterLocals>): TypedRouter<RouterMiddlewareProps, RouterLocals>;
|
|
252
326
|
private registerRoute;
|
|
253
327
|
private createBodyValidationMiddleware;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minisylar/express-typed-router",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "A strongly-typed Express router with Zod validation and automatic type inference for params, body, query, and middleware",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/zod-router.cjs",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
64
64
|
"rimraf": "^6.0.1",
|
|
65
65
|
"semantic-release": "^24.2.7",
|
|
66
|
-
"tsdown": "^0.
|
|
66
|
+
"tsdown": "^0.14.0",
|
|
67
67
|
"typescript": "^5.8.3",
|
|
68
68
|
"zod": "^3.25.76"
|
|
69
69
|
},
|