mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 12:14:40 +01:00
cleanup
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { createTRPCProxyClient, httpBatchLink, loggerLink } from '@trpc/client'
|
||||
import { httpBatchLink, loggerLink } from '@trpc/client'
|
||||
import superjson from 'superjson'
|
||||
import { FetchError } from 'ofetch'
|
||||
import { createTRPCNuxtClient } from 'trpc-nuxt/client'
|
||||
@@ -10,18 +10,18 @@ export default defineNuxtPlugin(() => {
|
||||
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)
|
||||
// }),
|
||||
loggerLink({
|
||||
enabled: opts =>
|
||||
process.env.NODE_ENV === 'development' ||
|
||||
(opts.direction === 'down' && opts.result instanceof Error)
|
||||
}),
|
||||
httpBatchLink({
|
||||
url: '/api/trpc',
|
||||
headers () {
|
||||
return headers
|
||||
},
|
||||
fetch: (input, options) =>
|
||||
$fetch.raw(input.toString(), options)
|
||||
globalThis.$fetch.raw(input.toString(), options)
|
||||
.catch((e) => {
|
||||
if (e instanceof FetchError && e.response) { return e.response }
|
||||
throw e
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { type CreateTRPCClientOptions, type inferRouterProxyClient, createTRPCProxyClient, httpBatchLink as _httpBatchLink } from '@trpc/client'
|
||||
import { type CreateTRPCClientOptions, type inferRouterProxyClient, createTRPCProxyClient } from '@trpc/client'
|
||||
import { type AnyRouter } from '@trpc/server'
|
||||
import { createFlatProxy, createRecursiveProxy } from '@trpc/server/shared'
|
||||
import { hash } from 'ohash'
|
||||
import { nanoid } from 'nanoid'
|
||||
import { type DecoratedProcedureRecord } from './types'
|
||||
// @ts-expect-error: Nuxt auto-imports
|
||||
import { getCurrentInstance, onScopeDispose, useAsyncData, useRequestHeaders, ref, unref } from '#imports'
|
||||
import { getCurrentInstance, onScopeDispose, useAsyncData, ref, unref } from '#imports'
|
||||
|
||||
/**
|
||||
* Calculates the key used for `useAsyncData` call
|
||||
|
||||
Reference in New Issue
Block a user