introduce TRPC and service layer

This commit is contained in:
Michael Dausmann
2023-02-05 11:55:49 +11:00
parent 791192a1ae
commit bba070d985
13 changed files with 307 additions and 58 deletions

22
plugins/trpcClient.ts Normal file
View File

@@ -0,0 +1,22 @@
import { createTRPCNuxtClient, httpBatchLink } from 'trpc-nuxt/client'
import type { AppRouter } from '~/server/api/trpc/[trpc]'
export default defineNuxtPlugin(() => {
/**
* createTRPCNuxtClient adds a `useQuery` composable
* built on top of `useAsyncData`.
*/
const client = createTRPCNuxtClient<AppRouter>({
links: [
httpBatchLink({
url: '/api/trpc',
}),
],
})
return {
provide: {
client,
},
}
})