feat: add file routing option

This commit is contained in:
wobsoriano
2022-11-05 19:22:19 -07:00
parent d9c8f877d3
commit 750783e860
33 changed files with 589 additions and 348 deletions

View File

@@ -0,0 +1,27 @@
import { httpBatchLink, loggerLink } from '@trpc/client'
import { createTRPCNuxtProxyClient } from 'trpc-nuxt/client'
import superjson from 'superjson'
import { AppRouter } from '~~/server/trpc/routers'
export default defineNuxtPlugin(() => {
const client = createTRPCNuxtProxyClient<AppRouter>({
transformer: superjson,
links: [
// adds pretty logs to your console in development and logs errors in production
loggerLink({
enabled: opts =>
process.env.NODE_ENV === 'development' ||
(opts.direction === 'down' && opts.result instanceof Error)
}),
httpBatchLink({
url: 'http://localhost:3000/api/trpc'
})
]
})
return {
provide: {
client
}
}
})