diff --git a/playground/plugins/trpc-client.ts b/playground/plugins/trpc-client.ts index 5dbb3f5..b3f756c 100644 --- a/playground/plugins/trpc-client.ts +++ b/playground/plugins/trpc-client.ts @@ -3,25 +3,25 @@ import { createTRPCNuxtProxyClient } from 'trpc-nuxt/client' import superjson from 'superjson' import type { AppRouter } from '~~/server/trpc/routers' -export default defineNuxtPlugin((nuxtApp) => { +export default defineNuxtPlugin(() => { const client = createTRPCNuxtProxyClient({ 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), + process.env.NODE_ENV === 'development' || + (opts.direction === 'down' && opts.result instanceof Error) }), httpBatchLink({ - url: 'http://localhost:3000/api/trpc', - }), - ], + url: 'http://localhost:3000/api/trpc' + }) + ] }) return { provide: { - client, - }, + client + } } }) diff --git a/playground/server/api/trpc/[trpc].ts b/playground/server/api/trpc/[trpc].ts index 3e76c39..4309837 100644 --- a/playground/server/api/trpc/[trpc].ts +++ b/playground/server/api/trpc/[trpc].ts @@ -8,12 +8,12 @@ export default createNuxtApiHandler({ * @link https://trpc.io/docs/context */ createContext, - onError({ error }) { + onError ({ error }) { if (error.code === 'INTERNAL_SERVER_ERROR') { // send to bug reporting console.error('Something went wrong', error) } - }, + } /** * @link https://trpc.io/docs/caching#api-response-caching */ diff --git a/playground/server/trpc/context.ts b/playground/server/trpc/context.ts index 9543a9f..cd78756 100644 --- a/playground/server/trpc/context.ts +++ b/playground/server/trpc/context.ts @@ -8,8 +8,8 @@ export type Context = inferAsyncReturnType * Creates context for an incoming request * @link https://trpc.io/docs/context */ -export async function createContext( - opts: H3Event, +export function createContext ( + opts: H3Event ) { // for API-response caching see https://trpc.io/docs/caching diff --git a/playground/server/trpc/routers/index.ts b/playground/server/trpc/routers/index.ts index 683f009..b552e46 100644 --- a/playground/server/trpc/routers/index.ts +++ b/playground/server/trpc/routers/index.ts @@ -4,7 +4,7 @@ import { userRouter } from './user' export const appRouter = router({ todo: todoRouter, - user: userRouter, + user: userRouter }) export type AppRouter = typeof appRouter diff --git a/playground/server/trpc/routers/todo.ts b/playground/server/trpc/routers/todo.ts index 871f77c..5f6ef0e 100644 --- a/playground/server/trpc/routers/todo.ts +++ b/playground/server/trpc/routers/todo.ts @@ -7,7 +7,7 @@ const TodoShape = z.object({ userId: z.number(), id: z.number(), title: z.string(), - completed: z.boolean(), + completed: z.boolean() }) export type Todo = z.infer @@ -27,7 +27,7 @@ export const todoRouter = router({ .mutation((req) => { return $fetch(`${baseURL}/todos`, { method: 'POST', - body: req.input, + body: req.input }) - }), + }) }) diff --git a/playground/server/trpc/routers/user.ts b/playground/server/trpc/routers/user.ts index 26ea42e..b3b9486 100644 --- a/playground/server/trpc/routers/user.ts +++ b/playground/server/trpc/routers/user.ts @@ -7,7 +7,7 @@ const UserShape = z.object({ id: z.number(), name: z.string(), username: z.string(), - email: z.string(), + email: z.string() }) export type User = z.infer @@ -27,7 +27,7 @@ export const userRouter = router({ .mutation((req) => { return $fetch(`${baseURL}/users`, { method: 'POST', - body: req.input, + body: req.input }) - }), + }) }) diff --git a/playground/server/trpc/trpc.ts b/playground/server/trpc/trpc.ts index c090769..600f632 100644 --- a/playground/server/trpc/trpc.ts +++ b/playground/server/trpc/trpc.ts @@ -5,19 +5,19 @@ import type { Context } from './context' const t = initTRPC.context().create({ transformer: superjson, - errorFormatter({ shape, error }) { + errorFormatter ({ shape, error }) { return { ...shape, data: { ...shape.data, zodError: - error.code === 'BAD_REQUEST' - && error.cause instanceof ZodError + error.code === 'BAD_REQUEST' && + error.cause instanceof ZodError ? error.cause!.flatten() - : null, - }, + : null + } } - }, + } }) /**