eslint fixes

This commit is contained in:
wobsoriano
2022-11-05 11:56:14 -07:00
parent e9081d00ad
commit e359702c41
7 changed files with 25 additions and 25 deletions

View File

@@ -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<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),
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
}
}
})

View File

@@ -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
*/

View File

@@ -8,8 +8,8 @@ export type Context = inferAsyncReturnType<typeof createContext>
* 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

View File

@@ -4,7 +4,7 @@ import { userRouter } from './user'
export const appRouter = router({
todo: todoRouter,
user: userRouter,
user: userRouter
})
export type AppRouter = typeof appRouter

View File

@@ -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<typeof TodoShape>
@@ -27,7 +27,7 @@ export const todoRouter = router({
.mutation((req) => {
return $fetch<Todo>(`${baseURL}/todos`, {
method: 'POST',
body: req.input,
body: req.input
})
}),
})
})

View File

@@ -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<typeof UserShape>
@@ -27,7 +27,7 @@ export const userRouter = router({
.mutation((req) => {
return $fetch<User>(`${baseURL}/users`, {
method: 'POST',
body: req.input,
body: req.input
})
}),
})
})

View File

@@ -5,19 +5,19 @@ import type { Context } from './context'
const t = initTRPC.context<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
}
}
},
}
})
/**