UNPKG

solid-start-trpc

Version:

```ts import { createSolidAPIHandler } from "solid-start-trpc";

29 lines (28 loc) 743 B
import { TRPCError } from "@trpc/server"; export function getPath(args) { const p = args.params.trpc; if (typeof p === "string") { return p; } if (Array.isArray(p)) { return p.join("/"); } return null; } export function notFoundError(opts) { const error = opts.router.getErrorShape({ error: new TRPCError({ message: 'Query "trpc" not found - is the file named `[trpc]`.ts or `[...trpc].ts`?', code: "INTERNAL_SERVER_ERROR", }), type: "unknown", ctx: undefined, path: undefined, input: undefined, }); const json = { id: -1, error, }; return new Response(JSON.stringify(json), { status: 500 }); }