MCPcopy Create free account
hub / github.com/ProNextJS/declarative-routing / makeDeleteRoute

Function makeDeleteRoute

assets/nextjs/makeRoute.tsx:383–417  ·  view source on GitHub ↗
(
  route: string,
  info: RouteInfo<Params, Search>
)

Source from the content-addressed store, hash-verified

381}
382
383export 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
419export function makeRoute<
420 Params extends z.ZodSchema,

Callers

nothing calls this directly

Calls 1

createRouteBuilderFunction · 0.70

Tested by

no test coverage detected