( route: string, info: RouteInfo<Params, Search> )
| 381 | } |
| 382 | |
| 383 | export function makeDeleteRoute< |
| 384 | Params extends z.ZodSchema, |
| 385 | Search extends z.ZodSchema |
| 386 | >( |
| 387 | route: string, |
| 388 | info: RouteInfo<Params, Search> |
| 389 | ): DeleteRouteBuilder<Params, Search> { |
| 390 | const urlBuilder = createRouteBuilder(route, info); |
| 391 | |
| 392 | const routeBuilder: DeleteRouteBuilder<Params, Search> = ( |
| 393 | p?: z.input<Params>, |
| 394 | search?: z.input<Search>, |
| 395 | options?: FetchOptions |
| 396 | ): Promise<void> => { |
| 397 | return fetch(urlBuilder(p, search), { |
| 398 | ...options, |
| 399 | method: "DELETE", |
| 400 | headers: { |
| 401 | ...(options?.headers || {}), |
| 402 | "Content-Type": "application/json" |
| 403 | } |
| 404 | }).then((res) => { |
| 405 | if (!res.ok) { |
| 406 | throw new Error(`Failed to fetch ${info.name}: ${res.statusText}`); |
| 407 | } |
| 408 | }); |
| 409 | }; |
| 410 | |
| 411 | routeBuilder.params = undefined as z.output<Params>; |
| 412 | routeBuilder.paramsSchema = info.params; |
| 413 | routeBuilder.search = undefined as z.output<Search>; |
| 414 | routeBuilder.searchSchema = info.search; |
| 415 | |
| 416 | return routeBuilder; |
| 417 | } |
| 418 | |
| 419 | export function makeRoute< |
| 420 | Params extends z.ZodSchema, |
nothing calls this directly
no test coverage detected