mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
add solid
This commit is contained in:
30
apps/cli/templates/api/orpc/web/solid/src/utils/orpc.ts.hbs
Normal file
30
apps/cli/templates/api/orpc/web/solid/src/utils/orpc.ts.hbs
Normal file
@@ -0,0 +1,30 @@
|
||||
import { createORPCClient } from "@orpc/client";
|
||||
import { RPCLink } from "@orpc/client/fetch";
|
||||
import { createORPCSolidQueryUtils } from "@orpc/solid-query";
|
||||
import { QueryCache, QueryClient } from "@tanstack/solid-query";
|
||||
import type { appRouter } from "../../../server/src/routers/index";
|
||||
import type { RouterClient } from "@orpc/server";
|
||||
|
||||
export const queryClient = new QueryClient({
|
||||
queryCache: new QueryCache({
|
||||
onError: (error) => {
|
||||
console.error(`Error: ${error.message}`);
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
export const link = new RPCLink({
|
||||
url: `${import.meta.env.VITE_SERVER_URL}/rpc`,
|
||||
{{#if auth}}
|
||||
fetch(url, options) {
|
||||
return fetch(url, {
|
||||
...options,
|
||||
credentials: "include",
|
||||
});
|
||||
},
|
||||
{{/if}}
|
||||
});
|
||||
|
||||
export const client: RouterClient<typeof appRouter> = createORPCClient(link);
|
||||
|
||||
export const orpc = createORPCSolidQueryUtils(client);
|
||||
Reference in New Issue
Block a user